diff --git a/Asaph.Core.UnitTests/Domain/SongDirectorTests.cs b/Asaph.Core.UnitTests/Domain/SongDirectorTests.cs
index 368da91..5226eaa 100644
--- a/Asaph.Core.UnitTests/Domain/SongDirectorTests.cs
+++ b/Asaph.Core.UnitTests/Domain/SongDirectorTests.cs
@@ -1,5 +1,7 @@
-using Asaph.Core.Domain.SongDirectorAggregate;
+using Asaph.Core.Domain;
+using Asaph.Core.Domain.SongDirectorAggregate;
using FluentResults;
+using System.Linq;
using Xunit;
namespace Asaph.Core.UnitTests.Domain
@@ -48,5 +50,131 @@ public static void TryCreate_Multiple_ReturnsExpectedIsSuccess(
Assert.Equal(expectedIsSuccess, songDirectorCreateResult.IsSuccess);
}
+
+ ///
+ /// Tests update a user's full name.
+ ///
+ /// New active indicator.
+ /// Expected success indicator.
+ [Theory]
+ [InlineData(true, false)]
+ [InlineData(false, true)]
+ [InlineData(null, false)]
+ public static void TryUpdateIsActive_Multiple_ReturnsExpectedIsSuccess(
+ bool? isActive,
+ bool expectedIsSuccess)
+ {
+ // Arrange
+
+ SongDirector songDirector = SongDirector
+ .TryCreate(
+ "Jane Doe",
+ "jane.doe@example.com",
+ "123-456-7890",
+ "Apprentice",
+ true)
+ .Value;
+
+ // Act
+
+ Result updateIsActiveResult = songDirector.TryUpdateIsActive(isActive);
+
+ // Assert
+
+ Assert.Equal(expectedIsSuccess, updateIsActiveResult.IsSuccess);
+ }
+
+ ///
+ /// Tests that an is returned in the result when
+ /// an attempt to change a song director's active indicator to the same value is made.
+ ///
+ [Fact]
+ public static void
+ TryUpdateIsActive_UnchangedIsActive_ReturnsUnchangedPropertyValueError()
+ {
+ // Arrange
+
+ bool isActive = true;
+
+ SongDirector songDirector = SongDirector
+ .TryCreate(
+ "Jane Doe",
+ "jane.doe@example.com",
+ "123-456-7890",
+ "Apprentice",
+ isActive)
+ .Value;
+
+ // Act
+
+ Result updateIsActiveResult = songDirector.TryUpdateIsActive(isActive);
+
+ // Assert
+
+ Assert.IsType(updateIsActiveResult.Errors.Single());
+ }
+
+ ///
+ /// Tests update a user's full name.
+ ///
+ /// New rank.
+ /// Expected success indicator.
+ [Theory]
+ [InlineData("Apprentice", false)]
+ [InlineData("Journeyer", true)]
+ [InlineData("", false)]
+ [InlineData(" ", false)]
+ [InlineData(null, true)]
+ public static void TryUpdateRank_Multiple_ReturnsExpectedIsSuccess(
+ string? rank, bool expectedIsSuccess)
+ {
+ // Arrange
+
+ SongDirector songDirector = SongDirector
+ .TryCreate(
+ "Jane Doe",
+ "jane.doe@example.com",
+ "123-456-7890",
+ "Apprentice",
+ true)
+ .Value;
+
+ // Act
+
+ Result updateRankResult = songDirector.TryUpdateRank(rank);
+
+ // Assert
+
+ Assert.Equal(expectedIsSuccess, updateRankResult.IsSuccess);
+ }
+
+ ///
+ /// Tests that an is returned in the result when
+ /// an attempt to change a song director's rank is made.
+ ///
+ [Fact]
+ public static void TryUpdateRank_UnchangedRank_ReturnsUnchangedPropertyValueError()
+ {
+ // Arrange
+
+ string rank = "Apprentice";
+
+ SongDirector songDirector = SongDirector
+ .TryCreate(
+ "Jane Doe",
+ "jane.doe@example.com",
+ "123-456-7890",
+ rank,
+ true)
+ .Value;
+
+ // Act
+
+ Result updateRankResult = songDirector.TryUpdateRank(rank);
+
+ // Assert
+
+ Assert.IsType(updateRankResult.Errors.Single());
+ }
}
}
diff --git a/Asaph.Core.UnitTests/Domain/UserTests.cs b/Asaph.Core.UnitTests/Domain/UserTests.cs
index 7f64eba..1f68515 100644
--- a/Asaph.Core.UnitTests/Domain/UserTests.cs
+++ b/Asaph.Core.UnitTests/Domain/UserTests.cs
@@ -1,5 +1,7 @@
+using Asaph.Core.Domain;
using Asaph.Core.Domain.UserAggregate;
using FluentResults;
+using System.Linq;
using Xunit;
namespace Asaph.Core.UnitTests.Domain
@@ -37,5 +39,189 @@ public static void TryCreate_Multiple_ReturnsExpectedIsSuccess(
Assert.Equal(expectedIsSuccess, result.IsSuccess);
}
+
+ ///
+ /// Tests updating a user's email address.
+ ///
+ /// Email address.
+ /// Expected success indicator.
+ [Theory]
+ [InlineData("vera.ilyinichna@example.com", false)]
+ [InlineData("vera.ilyinichna@example2.com", true)]
+ [InlineData("vera.ilyinichnaexample2.com", false)]
+ [InlineData("vera.ilyinichna@example2com", false)]
+ [InlineData("", false)]
+ [InlineData(" ", false)]
+ [InlineData(null, false)]
+ public static void TryUpdateEmailAddress_Multiple_ReturnsExpectedIsSuccess(
+ string? emailAddress,
+ bool expectedIsSuccess)
+ {
+ // Arrange
+
+ User user = User
+ .TryCreate(
+ "Vera Ilyinichna",
+ "vera.ilyinichna@example.com",
+ "123-456-7890")
+ .Value;
+
+ // Act
+
+ Result updateEmailAddressResult = user.TryUpdateEmailAddress(emailAddress);
+
+ // Assert
+
+ Assert.Equal(expectedIsSuccess, updateEmailAddressResult.IsSuccess);
+ }
+
+ ///
+ /// Tests that an is returned in the result when
+ /// an attempt to change a user's email address with the same value is made.
+ ///
+ [Fact]
+ public static void
+ TryUpdateEmailAddress_UnchangedEmailAddress_ReturnsUnchangedPropertyValueError()
+ {
+ // Arrange
+
+ string emailAddress = "vera.ilyinichna@example.com";
+
+ User user = User
+ .TryCreate(
+ "Vera Ilyinichna",
+ emailAddress,
+ "123-456-7890")
+ .Value;
+
+ // Act
+
+ Result updateEmailAddressResult = user.TryUpdateEmailAddress(emailAddress);
+
+ // Assert
+
+ Assert.IsType(updateEmailAddressResult.Errors.Single());
+ }
+
+ ///
+ /// Tests update a user's full name.
+ ///
+ /// New full name.
+ /// Expected success indicator.
+ [Theory]
+ [InlineData("Harpa Stefansdottir", false)]
+ [InlineData("Harpa Gunnarsson", true)]
+ [InlineData("", false)]
+ [InlineData(" ", false)]
+ [InlineData(null, false)]
+ public static void TryUpdateFullName_Multiple_ReturnsExpectedIsSuccess(
+ string? fullName,
+ bool expectedIsSuccess)
+ {
+ // Arrange
+
+ User user = User
+ .TryCreate(
+ "Harpa Stefansdottir",
+ "harpa.stefansdottir@example.com",
+ "123-456-7890")
+ .Value;
+
+ // Act
+
+ Result updateFullNameResult = user.TryUpdateFullName(fullName);
+
+ // Assert
+
+ Assert.Equal(expectedIsSuccess, updateFullNameResult.IsSuccess);
+ }
+
+ ///
+ /// Tests that an is returned in the result when
+ /// an attempt to change a user's full name with the same value is made.
+ ///
+ [Fact]
+ public static void TryUpdateFullName_UnchangedFullName_ReturnsUnchangedPropertyValueError()
+ {
+ // Arrange
+
+ string fullName = "Sato Gota";
+
+ User user = User
+ .TryCreate(
+ fullName,
+ "sato.gota@example.com",
+ "123-456-7890")
+ .Value;
+
+ // Act
+
+ Result updateFullNameResult = user.TryUpdateFullName(fullName);
+
+ // Assert
+
+ Assert.IsType(updateFullNameResult.Errors.Single());
+ }
+
+ ///
+ /// Tests update a user's full name.
+ ///
+ /// New phone number.
+ /// Expected success indicator.
+ [Theory]
+ [InlineData("123-456-7890", false)]
+ [InlineData("234-567-8901", true)]
+ [InlineData("", false)]
+ [InlineData(" ", false)]
+ [InlineData(null, true)]
+ public static void TryUpdatePhoneNumber_Multiple_ReturnsExpectedIsSuccess(
+ string? phoneNumber,
+ bool expectedIsSuccess)
+ {
+ // Arrange
+
+ User user = User
+ .TryCreate(
+ "Zhang Xia",
+ "zhang.xia@example.com",
+ "123-456-7890")
+ .Value;
+
+ // Act
+
+ Result updateFullNameResult = user.TryUpdatePhoneNumber(phoneNumber);
+
+ // Assert
+
+ Assert.Equal(expectedIsSuccess, updateFullNameResult.IsSuccess);
+ }
+
+ ///
+ /// Tests that an is returned in the result when
+ /// an attempt to change a user's phone number with the same value is made.
+ ///
+ [Fact]
+ public static void
+ TryUpdatePhoneNumber_UnchangedPhoneNumber_ReturnsUnchangedPropertyValueError()
+ {
+ // Arrange
+
+ string phoneNumber = "123-456-7890";
+
+ User user = User
+ .TryCreate(
+ "Zhang Xia",
+ "zhang.xia@example.com",
+ phoneNumber)
+ .Value;
+
+ // Act
+
+ Result updateFullNameResult = user.TryUpdatePhoneNumber(phoneNumber);
+
+ // Assert
+
+ Assert.IsType(updateFullNameResult.Errors.Single());
+ }
}
}
diff --git a/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestBoundary.cs b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestBoundary.cs
new file mode 100644
index 0000000..57e5f66
--- /dev/null
+++ b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestBoundary.cs
@@ -0,0 +1,40 @@
+using Asaph.Core.UseCases.UpdateSongDirector;
+
+namespace Asaph.Core.UnitTests.UseCases;
+
+///
+/// Test implementation of the update song director boundary.
+///
+internal class UpdateSongDirectorTestBoundary
+ : IUpdateSongDirectorBoundary
+{
+ ///
+ public UpdateSongDirectorResponse InsufficientPermissions(UpdateSongDirectorResponse response)
+ {
+ return response;
+ }
+
+ ///
+ public UpdateSongDirectorResponse InvalidRequest(UpdateSongDirectorResponse response)
+ {
+ return response;
+ }
+
+ ///
+ public UpdateSongDirectorResponse RequesterRankNotFound(UpdateSongDirectorResponse response)
+ {
+ return response;
+ }
+
+ ///
+ public UpdateSongDirectorResponse SongDirectorUpdated(UpdateSongDirectorResponse response)
+ {
+ return response;
+ }
+
+ ///
+ public UpdateSongDirectorResponse SongDirectorUpdateFailed(UpdateSongDirectorResponse response)
+ {
+ return response;
+ }
+}
diff --git a/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestCaseBuilder.cs b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestCaseBuilder.cs
new file mode 100644
index 0000000..5131c36
--- /dev/null
+++ b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestCaseBuilder.cs
@@ -0,0 +1,135 @@
+using Asaph.Core.Domain.SongDirectorAggregate;
+using Asaph.Core.UseCases.UpdateSongDirector;
+using System.Collections.Generic;
+
+namespace Asaph.Core.UnitTests.UseCases;
+
+///
+/// Builds test cases for the Update Song Director use case.
+///
+internal class UpdateSongDirectorTestCaseBuilder
+{
+ private readonly string? _requesterId;
+
+ private readonly string? _requesterRank;
+
+ private string? _expectedMessage;
+
+ private UpdateSongDirectorRequest? _request;
+
+ private IEnumerable _existingSongDirectors = new List();
+
+ private SongDirector? _songDirectorToUpdate;
+
+ private UpdateSongDirectorTestCaseBuilder(string? requesterId, string? requesterRank)
+ {
+ _requesterId = requesterId;
+ _requesterRank = requesterRank;
+ }
+
+ ///
+ /// Sets up the requester for the test case.
+ ///
+ /// Requester id.
+ /// Requester rank.
+ /// .
+ public static UpdateSongDirectorTestCaseBuilder Requester(
+ string? requesterId, string? requesterRank)
+ {
+ return new(requesterId, requesterRank);
+ }
+
+ ///
+ /// Builds the test case.
+ ///
+ /// Test case parameters.
+ public object?[] Build()
+ {
+ return new object?[]
+ {
+ _requesterRank,
+ _request,
+ _songDirectorToUpdate,
+ _existingSongDirectors,
+ _expectedMessage,
+ };
+ }
+
+ ///
+ /// Sets existing song directors.
+ ///
+ /// Existing song directors.
+ /// .
+ public UpdateSongDirectorTestCaseBuilder ExistingSongDirectors(
+ IEnumerable existingSongDirectors)
+ {
+ _existingSongDirectors = existingSongDirectors;
+
+ return this;
+ }
+
+ ///
+ /// Configures the expected message.
+ ///
+ /// Expected message.
+ /// .
+ public UpdateSongDirectorTestCaseBuilder ExpectedMessage(string expectedMessage)
+ {
+ _expectedMessage = expectedMessage;
+
+ return this;
+ }
+
+ ///
+ /// Configures the request.
+ ///
+ /// Song director id.
+ /// Full name.
+ /// Email address.
+ /// Phone number.
+ /// Rank.
+ /// Active indicator.
+ /// .
+ public UpdateSongDirectorTestCaseBuilder Request(
+ string? songDirectorId,
+ string? fullName,
+ string? emailAddress,
+ string? phoneNumber,
+ string? rank,
+ bool? isActive)
+ {
+ _request = new UpdateSongDirectorRequest(
+ _requesterId, songDirectorId, fullName, emailAddress, phoneNumber, rank, isActive);
+
+ return this;
+ }
+
+ ///
+ /// Configures the song director to update.
+ ///
+ /// Id.
+ /// Full name.
+ /// Email address.
+ /// Phone number.
+ /// Rank.
+ /// Active indicator.
+ /// .
+ public UpdateSongDirectorTestCaseBuilder SongDirectorToUpdate(
+ string? id,
+ string? fullName,
+ string? emailAddress,
+ string? phoneNumber,
+ string? rank,
+ bool? isActive)
+ {
+ SongDirector songDirectorToUpdate = SongDirector
+ .TryCreate(fullName, emailAddress, phoneNumber, rank, isActive)
+ .Value;
+
+ songDirectorToUpdate.UpdateId(id);
+
+ _songDirectorToUpdate = songDirectorToUpdate;
+
+ return this;
+ }
+}
\ No newline at end of file
diff --git a/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestData.cs b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestData.cs
new file mode 100644
index 0000000..2f40837
--- /dev/null
+++ b/Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestData.cs
@@ -0,0 +1,224 @@
+using Asaph.Core.Domain.SongDirectorAggregate;
+using System.Collections;
+using System.Collections.Generic;
+
+namespace Asaph.Core.UnitTests.UseCases;
+
+///
+/// Test data for Update Song Director tests.
+///
+public class UpdateSongDirectorTestData : IEnumerable