Skip to content

Commit

Permalink
#545 Added tests to increase coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ghanam committed Dec 5, 2024
1 parent 9cd7ec3 commit b562e4b
Showing 1 changed file with 113 additions and 0 deletions.
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);
}
}

0 comments on commit b562e4b

Please sign in to comment.