Skip to content

Commit

Permalink
Add three new unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed-Ghanam committed Oct 8, 2024
1 parent 3999344 commit 5310621
Showing 1 changed file with 34 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Immutable;
using System.Threading.Tasks;

using Altinn.Profile.Controllers;
Expand Down Expand Up @@ -29,6 +28,40 @@ public ContactDetailsControllerTests()
_controller = new ContactDetailsController(_loggerMock.Object, _mockContactDetailsRetriever.Object);
}

[Fact]
public void Constructor_NullLogger_ThrowsArgumentNullException()
{
// Arrange
var contactDetailsRetrieverMock = new Mock<IContactDetailsRetriever>();

// Act & Assert
Assert.Throws<ArgumentNullException>(() => new ContactDetailsController(null, contactDetailsRetrieverMock.Object));
}

[Fact]
public void Constructor_NullContactDetailsRetriever_ThrowsArgumentNullException()
{
// Arrange
var loggerMock = new Mock<ILogger<ContactDetailsController>>();

// Act & Assert
Assert.Throws<ArgumentNullException>(() => new ContactDetailsController(loggerMock.Object, null));
}

[Fact]
public void Constructor_ValidParameters_InitializesCorrectly()
{
// Arrange
var loggerMock = new Mock<ILogger<ContactDetailsController>>();
var contactDetailsRetrieverMock = new Mock<IContactDetailsRetriever>();

// Act
var controller = new ContactDetailsController(loggerMock.Object, contactDetailsRetrieverMock.Object);

// Assert
Assert.NotNull(controller);
}

[Fact]
public async Task PostLookup_DoesNotBlock_WhenServiceCallIsLongRunning()
{
Expand Down

0 comments on commit 5310621

Please sign in to comment.