コード例 #1
0
    /// <summary>
    /// Tries to add a song director.
    /// </summary>
    /// <param name="request">The add song director request.</param>
    /// <returns>The result of the request.</returns>
    private async Task <TOutput> TryAddSongDirector(AddSongDirectorRequest request)
    {
        // Validate the new song director
        Result <SongDirector> createSongDirectorResult = SongDirector.TryCreate(
            request.FullName,
            request.EmailAddress,
            request.PhoneNumber,
            request.RankName,
            request.IsActive);

        // Validation failure
        if (createSongDirectorResult.IsFailed)
        {
            return(ValidationFailure(createSongDirectorResult));
        }

        SongDirector songDirector = createSongDirectorResult.Value;

        // Add the song director
        Result <SongDirector> addSongDirectorResult = await _songDirectorRepository
                                                      .TryAddAsync(songDirector)
                                                      .ConfigureAwait(false);

        if (addSongDirectorResult.IsFailed)
        {
            return(FailedToAddSongDirector(addSongDirectorResult));
        }

        SongDirectorUseCaseModel addedSongDirector = SongDirectorUseCaseModel
                                                     .GrandmasterView(songDirector);

        return(SongDirectorAdded(addedSongDirector));
    }
コード例 #2
0
    public static async Task TryUpdateAsync_ExistingSongDirector_Succeeds(
        string awsRegionSystemName,
        bool useDynamoDBLocal,
        string songDirectorId,
        string fullName,
        string emailAddress,
        string phoneNumber,
        string rankName,
        bool isActive)
    {
        // Arrange

        SongDirector songDirector = SongDirector
                                    .TryCreate(fullName, emailAddress, phoneNumber, rankName, isActive)
                                    .Value;

        songDirector.UpdateId(songDirectorId);

        AggregateSongDirectorRepository aggregateSongDirectorRepository =
            GetAggregateSongDirectorRepository(awsRegionSystemName, useDynamoDBLocal);

        // Act

        Result updateResult = await aggregateSongDirectorRepository
                              .TryUpdateAsync(songDirector)
                              .ConfigureAwait(false);

        // Assert

        Assert.True(updateResult.IsSuccess);
    }
コード例 #3
0
        public static void TryCreate_Multiple_ReturnsExpectedIsSuccess(
            string?fullName,
            string?emailAddress,
            string?phoneNumber,
            string?rankName,
            bool isActive,
            bool expectedIsSuccess)
        {
            // Act

            Result <SongDirector> songDirectorCreateResult = SongDirector.TryCreate(
                fullName, emailAddress, phoneNumber, rankName, isActive);

            // Assert

            Assert.Equal(expectedIsSuccess, songDirectorCreateResult.IsSuccess);
        }