-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure nace is filtered correctly (#15)
- Loading branch information
1 parent
2f90466
commit 26e1a36
Showing
5 changed files
with
116 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
test/Dan.Plugin.Tilda.Test/Extensions/BrEntityRegisterEntryExtensionsTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
using Dan.Plugin.Tilda.Extensions; | ||
using Dan.Plugin.Tilda.Models; | ||
|
||
namespace Dan.Plugin.Tilda.Test.Extensions; | ||
|
||
public class BrEntityRegisterEntryExtensionsTests | ||
{ | ||
[Fact] | ||
public void MatchesFilterParameters_ParametersIsNull_ReturnTrue() | ||
{ | ||
// Arrange | ||
TildaParameters? tildaParameters = null; | ||
|
||
var brEntity = new BREntityRegisterEntry(); | ||
|
||
// Act | ||
var actual = brEntity.MatchesFilterParameters(tildaParameters); | ||
|
||
// Assert | ||
actual.Should().BeTrue(); | ||
} | ||
|
||
[Fact] | ||
public void MatchesFilterParameters_ParametersAreNull_ReturnTrue() | ||
{ | ||
// Arrange | ||
var tildaParameters = new TildaParameters( | ||
fromDate: null, | ||
toDate: null, | ||
npdid: null, | ||
includeSubunits: null, | ||
sourceFilter: null, | ||
identifier: null, | ||
filter: null, | ||
year: null, | ||
month: null, | ||
postcode: null, | ||
municipalityNumber: null, | ||
nace: null | ||
); | ||
|
||
var brEntity = new BREntityRegisterEntry(); | ||
|
||
// Act | ||
var actual = brEntity.MatchesFilterParameters(tildaParameters); | ||
|
||
// Assert | ||
actual.Should().BeTrue(); | ||
} | ||
|
||
[Theory] | ||
[InlineData("nace",null,null,null,false)] | ||
[InlineData("nace","nope",null,null,false)] | ||
[InlineData("nace","nope","nope","nope",false)] | ||
[InlineData("nace","nace",null,null,true)] | ||
[InlineData("nace","nace","nope","nope",true)] | ||
[InlineData("nace","nace","nace","nace",true)] | ||
[InlineData("nace","nacee","nacee","nacee",true)] | ||
[InlineData("nacee","nace","nace","nace",false)] | ||
public void MatchesFilterParameters_Theory( | ||
string nace, string code1, string code2, string code3, bool expected) | ||
{ | ||
// Arrange | ||
var tildaParameters = new TildaParameters( | ||
fromDate: null, | ||
toDate: null, | ||
npdid: null, | ||
includeSubunits: null, | ||
sourceFilter: null, | ||
identifier: null, | ||
filter: null, | ||
year: null, | ||
month: null, | ||
postcode: null, | ||
municipalityNumber: null, | ||
nace: nace | ||
); | ||
|
||
var brEntity = new BREntityRegisterEntry | ||
{ | ||
Naeringskode1 = new InstitusjonellSektorkode { Kode = code1 }, | ||
Naeringskode2 = new InstitusjonellSektorkode { Kode = code2 }, | ||
Naeringskode3 = new InstitusjonellSektorkode { Kode = code3 }, | ||
}; | ||
|
||
// Act | ||
var actual = brEntity.MatchesFilterParameters(tildaParameters); | ||
|
||
// Assert | ||
actual.Should().Be(expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
global using Xunit; | ||
global using FluentAssertions; |
This file was deleted.
Oops, something went wrong.