-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement two unit tests to validate the functionality of the user co…
…ntact details retrieval use case.
- Loading branch information
1 parent
3723e74
commit 643d984
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
test/Altinn.Profile.Tests/Profile.Integrations/UserContactDetailsRetrieverTests.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,66 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Immutable; | ||
using System.Threading.Tasks; | ||
|
||
using Altinn.Profile.Core; | ||
using Altinn.Profile.Integrations.Entities; | ||
using Altinn.Profile.Integrations.Services; | ||
using Altinn.Profile.Models; | ||
using Altinn.Profile.UseCases; | ||
|
||
using Moq; | ||
|
||
using Xunit; | ||
|
||
namespace Altinn.Profile.Tests.Profile.Integrations; | ||
|
||
public class UserContactDetailsRetrieverTests | ||
{ | ||
private readonly Mock<IPersonService> _mockRegisterService; | ||
private readonly UserContactDetailsRetriever _retriever; | ||
|
||
public UserContactDetailsRetrieverTests() | ||
{ | ||
_mockRegisterService = new Mock<IPersonService>(); | ||
_retriever = new UserContactDetailsRetriever(_mockRegisterService.Object); | ||
} | ||
|
||
[Fact] | ||
public async Task RetrieveAsync_ThrowsArgumentNullException_WhenLookupCriteriaIsNull() | ||
{ | ||
// Act & Assert | ||
await Assert.ThrowsAsync<ArgumentNullException>(() => _retriever.RetrieveAsync(null)); | ||
} | ||
|
||
[Fact] | ||
public async Task RetrieveAsync_ReturnsFalse_WhenNationalIdentityNumbersIsEmpty() | ||
{ | ||
// Arrange | ||
var lookupCriteria = new UserContactPointLookup { NationalIdentityNumbers = [] }; | ||
|
||
// Act | ||
var result = await _retriever.RetrieveAsync(lookupCriteria); | ||
|
||
// Assert | ||
Assert.False(result.IsSuccess); | ||
} | ||
|
||
[Fact] | ||
public async Task RetrieveAsync_ReturnsFalse_WhenNoContactDetailsFound() | ||
{ | ||
// Arrange | ||
var lookupCriteria = new UserContactPointLookup | ||
{ | ||
NationalIdentityNumbers = new List<string> { "08119043698" } | ||
}; | ||
|
||
_mockRegisterService.Setup(s => s.GetUserContactAsync(lookupCriteria.NationalIdentityNumbers)).ReturnsAsync(false); | ||
|
||
// Act | ||
var result = await _retriever.RetrieveAsync(lookupCriteria); | ||
|
||
// Assert | ||
Assert.False(result.IsSuccess); | ||
} | ||
} |