-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOrganisationsnummerTests.cs
74 lines (63 loc) · 2.41 KB
/
OrganisationsnummerTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using Xunit;
namespace Organisationsnummer.Tests;
public class OrganisationsnummerTests
{
[Theory]
[ClassData(typeof(InvalidDataProvider))]
public void TestThrowOnInvalid(OrganisationsnummerData input)
{
Assert.Throws<OrganisationsnummerException>(() =>
{
Organisationsnummer.Parse(input.LongFormat);
});
Assert.Throws<OrganisationsnummerException>(() =>
{
Organisationsnummer.Parse(input.ShortFormat);
});
}
[Theory]
[ClassData(typeof(DataProvider))]
public void TestValidateOrgNumbers(OrganisationsnummerData input)
{
Assert.Equal(input.Valid, Organisationsnummer.Valid(input.LongFormat));
Assert.Equal(input.Valid, Organisationsnummer.Valid(input.ShortFormat));
}
[Theory]
[ClassData(typeof(ValidDataProvider))]
public void TestFormatWithOutSeparator(OrganisationsnummerData input)
{
Assert.Equal(input.ShortFormat, Organisationsnummer.Parse(input.LongFormat).Format(false));
Assert.Equal(input.ShortFormat, Organisationsnummer.Parse(input.ShortFormat).Format(false));
}
[Theory]
[ClassData(typeof(ValidDataProvider))]
public void TestFormatWithSeparator(OrganisationsnummerData input)
{
Assert.Equal(input.LongFormat, Organisationsnummer.Parse(input.LongFormat).Format(true));
// If short format in, we must presume it's not a + expected.
Assert.Equal(input.LongFormat.Replace('+', '-'), Organisationsnummer.Parse(input.ShortFormat).Format(true));
}
[Theory]
[ClassData(typeof(ValidDataProvider))]
public void TestGetType(OrganisationsnummerData input)
{
Assert.Equal(input.Type, Organisationsnummer.Parse(input.ShortFormat).Type);
Assert.Equal(input.Type, Organisationsnummer.Parse(input.LongFormat).Type);
}
[Theory]
[ClassData(typeof(ValidDataProvider))]
public void TestGetVat(OrganisationsnummerData input)
{
Assert.Equal(input.VatNumber, Organisationsnummer.Parse(input.ShortFormat).VatNumber);
Assert.Equal(input.VatNumber, Organisationsnummer.Parse(input.LongFormat).VatNumber);
}
[Theory]
[InlineData("121212121212")]
[InlineData("121212-1212")]
public void TestWithPersonnummer(string input)
{
var nr = Organisationsnummer.Parse(input);
Assert.Equal("Enskild firma", nr.Type);
Assert.True(nr.IsPersonnummer);
}
}