From 53106215214d1c8133cb063a5633f75593ce30d5 Mon Sep 17 00:00:00 2001 From: Ahmed-Ghanam Date: Tue, 8 Oct 2024 17:04:15 +0200 Subject: [PATCH] Add three new unit tests --- .../ContactDetailsControllerTests.cs | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/test/Altinn.Profile.Tests/IntegrationTests/API/Controllers/ContactDetailsControllerTests.cs b/test/Altinn.Profile.Tests/IntegrationTests/API/Controllers/ContactDetailsControllerTests.cs index ea0792e..5d39b94 100644 --- a/test/Altinn.Profile.Tests/IntegrationTests/API/Controllers/ContactDetailsControllerTests.cs +++ b/test/Altinn.Profile.Tests/IntegrationTests/API/Controllers/ContactDetailsControllerTests.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Immutable; using System.Threading.Tasks; using Altinn.Profile.Controllers; @@ -29,6 +28,40 @@ public ContactDetailsControllerTests() _controller = new ContactDetailsController(_loggerMock.Object, _mockContactDetailsRetriever.Object); } + [Fact] + public void Constructor_NullLogger_ThrowsArgumentNullException() + { + // Arrange + var contactDetailsRetrieverMock = new Mock(); + + // Act & Assert + Assert.Throws(() => new ContactDetailsController(null, contactDetailsRetrieverMock.Object)); + } + + [Fact] + public void Constructor_NullContactDetailsRetriever_ThrowsArgumentNullException() + { + // Arrange + var loggerMock = new Mock>(); + + // Act & Assert + Assert.Throws(() => new ContactDetailsController(loggerMock.Object, null)); + } + + [Fact] + public void Constructor_ValidParameters_InitializesCorrectly() + { + // Arrange + var loggerMock = new Mock>(); + var contactDetailsRetrieverMock = new Mock(); + + // Act + var controller = new ContactDetailsController(loggerMock.Object, contactDetailsRetrieverMock.Object); + + // Assert + Assert.NotNull(controller); + } + [Fact] public async Task PostLookup_DoesNotBlock_WhenServiceCallIsLongRunning() {