-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#545 Added tests to increase coverage.
- Loading branch information
1 parent
9cd7ec3
commit b562e4b
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
...tinn.Notifications.Tests/Notifications.Core/TestingModels/PartyDetailsLookupBatchTests.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,113 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using Altinn.Notifications.Core.Models.Parties; | ||
|
||
using Xunit; | ||
|
||
namespace Altinn.Notifications.Tests.Notifications.Core.TestingModels; | ||
|
||
public class PartyDetailsLookupBatchTests | ||
{ | ||
[Fact] | ||
public void Constructor_DoesNotThrow_WhenBothListsAreProvided() | ||
{ | ||
// Arrange | ||
var organizationNumbers = new List<string> { "313556263" }; | ||
var socialSecurityNumbers = new List<string> { "16877298896" }; | ||
|
||
// Act | ||
var batch = new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers); | ||
|
||
// Assert | ||
Assert.NotNull(batch); | ||
Assert.NotEmpty(batch.OrganizationNumbers); | ||
Assert.NotEmpty(batch.SocialSecurityNumbers); | ||
Assert.Single(batch.OrganizationNumbers, "313556263"); | ||
Assert.Single(batch.SocialSecurityNumbers, "16877298896"); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_DoesNotThrow_WhenOrganizationNumbersIsProvided() | ||
{ | ||
// Arrange | ||
List<string>? socialSecurityNumbers = null; | ||
var organizationNumbers = new List<string> { "314727878" }; | ||
|
||
// Act | ||
var batch = new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers); | ||
|
||
// Assert | ||
Assert.NotNull(batch); | ||
Assert.NotEmpty(batch.OrganizationNumbers); | ||
Assert.Single(batch.OrganizationNumbers, "314727878"); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_DoesNotThrow_WhenSocialSecurityNumbersIsProvided() | ||
{ | ||
// Arrange | ||
List<string>? organizationNumbers = null; | ||
var socialSecurityNumbers = new List<string> { "55869600449" }; | ||
|
||
// Act | ||
var batch = new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers); | ||
|
||
// Assert | ||
Assert.NotNull(batch); | ||
Assert.NotEmpty(batch.SocialSecurityNumbers); | ||
Assert.Single(batch.SocialSecurityNumbers, "55869600449"); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_ThrowsArgumentException_WhenBothListsAreEmpty() | ||
{ | ||
// Arrange | ||
List<string>? organizationNumbers = []; | ||
List<string>? socialSecurityNumbers = []; | ||
|
||
// Act & Assert | ||
var exception = Assert.Throws<ArgumentException>(() => new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers)); | ||
|
||
Assert.Equal("At least one of organizationNumbers or socialSecurityNumbers must be provided.", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_ThrowsArgumentException_WhenBothListsAreNull() | ||
{ | ||
// Arrange | ||
List<string>? organizationNumbers = null; | ||
List<string>? socialSecurityNumbers = null; | ||
|
||
// Act & Assert | ||
var exception = Assert.Throws<ArgumentException>(() => new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers)); | ||
|
||
Assert.Equal("At least one of organizationNumbers or socialSecurityNumbers must be provided.", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_ThrowsArgumentException_WhenOrganizationNumbersIsEmptyAndSocialSecurityNumbersIsNull() | ||
{ | ||
// Arrange | ||
List<string>? organizationNumbers = []; | ||
List<string>? socialSecurityNumbers = null; | ||
|
||
// Act & Assert | ||
var exception = Assert.Throws<ArgumentException>(() => new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers)); | ||
|
||
Assert.Equal("At least one of organizationNumbers or socialSecurityNumbers must be provided.", exception.Message); | ||
} | ||
|
||
[Fact] | ||
public void Constructor_ThrowsArgumentException_WhenOrganizationNumbersIsNullAndSocialSecurityNumbersIsEmpty() | ||
{ | ||
// Arrange | ||
List<string>? organizationNumbers = null; | ||
List<string>? socialSecurityNumbers = []; | ||
|
||
// Act & Assert | ||
var exception = Assert.Throws<ArgumentException>(() => new PartyDetailsLookupBatch(organizationNumbers, socialSecurityNumbers)); | ||
|
||
Assert.Equal("At least one of organizationNumbers or socialSecurityNumbers must be provided.", exception.Message); | ||
} | ||
} |