-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a220366
commit f54ffa5
Showing
16 changed files
with
1,451 additions
and
81 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -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); | ||
} | ||
|
||
/// <summary> | ||
/// Tests update a user's full name. | ||
/// </summary> | ||
/// <param name="isActive">New active indicator.</param> | ||
/// <param name="expectedIsSuccess">Expected success indicator.</param> | ||
[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", | ||
"[email protected]", | ||
"123-456-7890", | ||
"Apprentice", | ||
true) | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateIsActiveResult = songDirector.TryUpdateIsActive(isActive); | ||
|
||
// Assert | ||
|
||
Assert.Equal(expectedIsSuccess, updateIsActiveResult.IsSuccess); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that an <see cref="UnchangedPropertyValueError"/> is returned in the result when | ||
/// an attempt to change a song director's active indicator to the same value is made. | ||
/// </summary> | ||
[Fact] | ||
public static void | ||
TryUpdateIsActive_UnchangedIsActive_ReturnsUnchangedPropertyValueError() | ||
{ | ||
// Arrange | ||
|
||
bool isActive = true; | ||
|
||
SongDirector songDirector = SongDirector | ||
.TryCreate( | ||
"Jane Doe", | ||
"[email protected]", | ||
"123-456-7890", | ||
"Apprentice", | ||
isActive) | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateIsActiveResult = songDirector.TryUpdateIsActive(isActive); | ||
|
||
// Assert | ||
|
||
Assert.IsType<UnchangedPropertyValueError>(updateIsActiveResult.Errors.Single()); | ||
} | ||
|
||
/// <summary> | ||
/// Tests update a user's full name. | ||
/// </summary> | ||
/// <param name="rank">New rank.</param> | ||
/// <param name="expectedIsSuccess">Expected success indicator.</param> | ||
[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", | ||
"[email protected]", | ||
"123-456-7890", | ||
"Apprentice", | ||
true) | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateRankResult = songDirector.TryUpdateRank(rank); | ||
|
||
// Assert | ||
|
||
Assert.Equal(expectedIsSuccess, updateRankResult.IsSuccess); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that an <see cref="UnchangedPropertyValueError"/> is returned in the result when | ||
/// an attempt to change a song director's rank is made. | ||
/// </summary> | ||
[Fact] | ||
public static void TryUpdateRank_UnchangedRank_ReturnsUnchangedPropertyValueError() | ||
{ | ||
// Arrange | ||
|
||
string rank = "Apprentice"; | ||
|
||
SongDirector songDirector = SongDirector | ||
.TryCreate( | ||
"Jane Doe", | ||
"[email protected]", | ||
"123-456-7890", | ||
rank, | ||
true) | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateRankResult = songDirector.TryUpdateRank(rank); | ||
|
||
// Assert | ||
|
||
Assert.IsType<UnchangedPropertyValueError>(updateRankResult.Errors.Single()); | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -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); | ||
} | ||
|
||
/// <summary> | ||
/// Tests updating a user's email address. | ||
/// </summary> | ||
/// <param name="emailAddress">Email address.</param> | ||
/// <param name="expectedIsSuccess">Expected success indicator.</param> | ||
[Theory] | ||
[InlineData("[email protected]", false)] | ||
[InlineData("[email protected]", 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", | ||
"[email protected]", | ||
"123-456-7890") | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateEmailAddressResult = user.TryUpdateEmailAddress(emailAddress); | ||
|
||
// Assert | ||
|
||
Assert.Equal(expectedIsSuccess, updateEmailAddressResult.IsSuccess); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that an <see cref="UnchangedPropertyValueError"/> is returned in the result when | ||
/// an attempt to change a user's email address with the same value is made. | ||
/// </summary> | ||
[Fact] | ||
public static void | ||
TryUpdateEmailAddress_UnchangedEmailAddress_ReturnsUnchangedPropertyValueError() | ||
{ | ||
// Arrange | ||
|
||
string emailAddress = "[email protected]"; | ||
|
||
User user = User | ||
.TryCreate( | ||
"Vera Ilyinichna", | ||
emailAddress, | ||
"123-456-7890") | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateEmailAddressResult = user.TryUpdateEmailAddress(emailAddress); | ||
|
||
// Assert | ||
|
||
Assert.IsType<UnchangedPropertyValueError>(updateEmailAddressResult.Errors.Single()); | ||
} | ||
|
||
/// <summary> | ||
/// Tests update a user's full name. | ||
/// </summary> | ||
/// <param name="fullName">New full name.</param> | ||
/// <param name="expectedIsSuccess">Expected success indicator.</param> | ||
[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", | ||
"[email protected]", | ||
"123-456-7890") | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateFullNameResult = user.TryUpdateFullName(fullName); | ||
|
||
// Assert | ||
|
||
Assert.Equal(expectedIsSuccess, updateFullNameResult.IsSuccess); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that an <see cref="UnchangedPropertyValueError"/> is returned in the result when | ||
/// an attempt to change a user's full name with the same value is made. | ||
/// </summary> | ||
[Fact] | ||
public static void TryUpdateFullName_UnchangedFullName_ReturnsUnchangedPropertyValueError() | ||
{ | ||
// Arrange | ||
|
||
string fullName = "Sato Gota"; | ||
|
||
User user = User | ||
.TryCreate( | ||
fullName, | ||
"[email protected]", | ||
"123-456-7890") | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateFullNameResult = user.TryUpdateFullName(fullName); | ||
|
||
// Assert | ||
|
||
Assert.IsType<UnchangedPropertyValueError>(updateFullNameResult.Errors.Single()); | ||
} | ||
|
||
/// <summary> | ||
/// Tests update a user's full name. | ||
/// </summary> | ||
/// <param name="phoneNumber">New phone number.</param> | ||
/// <param name="expectedIsSuccess">Expected success indicator.</param> | ||
[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", | ||
"[email protected]", | ||
"123-456-7890") | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateFullNameResult = user.TryUpdatePhoneNumber(phoneNumber); | ||
|
||
// Assert | ||
|
||
Assert.Equal(expectedIsSuccess, updateFullNameResult.IsSuccess); | ||
} | ||
|
||
/// <summary> | ||
/// Tests that an <see cref="UnchangedPropertyValueError"/> is returned in the result when | ||
/// an attempt to change a user's phone number with the same value is made. | ||
/// </summary> | ||
[Fact] | ||
public static void | ||
TryUpdatePhoneNumber_UnchangedPhoneNumber_ReturnsUnchangedPropertyValueError() | ||
{ | ||
// Arrange | ||
|
||
string phoneNumber = "123-456-7890"; | ||
|
||
User user = User | ||
.TryCreate( | ||
"Zhang Xia", | ||
"[email protected]", | ||
phoneNumber) | ||
.Value; | ||
|
||
// Act | ||
|
||
Result updateFullNameResult = user.TryUpdatePhoneNumber(phoneNumber); | ||
|
||
// Assert | ||
|
||
Assert.IsType<UnchangedPropertyValueError>(updateFullNameResult.Errors.Single()); | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Asaph.Core.UnitTests/UseCases/UpdateSongDirectorTestBoundary.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,40 @@ | ||
using Asaph.Core.UseCases.UpdateSongDirector; | ||
|
||
namespace Asaph.Core.UnitTests.UseCases; | ||
|
||
/// <summary> | ||
/// Test implementation of the update song director boundary. | ||
/// </summary> | ||
internal class UpdateSongDirectorTestBoundary | ||
: IUpdateSongDirectorBoundary<UpdateSongDirectorResponse> | ||
{ | ||
/// <inheritdoc/> | ||
public UpdateSongDirectorResponse InsufficientPermissions(UpdateSongDirectorResponse response) | ||
{ | ||
return response; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public UpdateSongDirectorResponse InvalidRequest(UpdateSongDirectorResponse response) | ||
{ | ||
return response; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public UpdateSongDirectorResponse RequesterRankNotFound(UpdateSongDirectorResponse response) | ||
{ | ||
return response; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public UpdateSongDirectorResponse SongDirectorUpdated(UpdateSongDirectorResponse response) | ||
{ | ||
return response; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public UpdateSongDirectorResponse SongDirectorUpdateFailed(UpdateSongDirectorResponse response) | ||
{ | ||
return response; | ||
} | ||
} |
Oops, something went wrong.