Example #1
0
        public void Should_Fail_By_Empty_Id()
        {
            // arrange
            var command = GetMemberCommandFake.InvalidByEmptyId().Generate();
            var sut     = new GetMemberValidator
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

            // act
            var result = sut.Validate(command);

            // assert
            result.AssertErrorsCount(1);
        }
Example #2
0
        public void Should_Succeed()
        {
            // arrange
            var command = GetMemberCommandFake.Valid().Generate();
            var sut     = new GetMemberValidator
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

            // act
            var result = sut.Validate(command);

            // assert
            result.Should().NotBeNull()
            .And.BeOfType <ValidationResult>();
            result.IsValid.Should().BeTrue();
        }
Example #3
0
        public async Task Handle_Should_Succeed_With_ValidCommand()
        {
            // arrange
            var expectedMember = MemberFake.GuildLeader().Generate();
            var command        = GetMemberCommandFake.Valid(expectedMember.Id).Generate();
            var repository     = MemberRepositoryMockBuilder.Create()
                                 .GetByIdSuccess(input: command.Id, output: expectedMember).Build();
            var sut = new GetMemberHandler(repository);

            // act
            var result = await sut.Handle(command, default);

            // assert
            result.Should().NotBeNull().And.BeOfType <SuccessResult>();
            result.Success.Should().BeTrue();
            result.Errors.Should().BeEmpty();
            result.As <SuccessResult>().StatusCode.Should().Be(StatusCodes.Status200OK);
            result.Data.Should().NotBeNull().And.BeOfType <MemberTestProxy>();
            result.Data.As <Member>().Id.Should().Be(expectedMember.Id);
            result.Data.As <Member>().GetGuild().Id.Should().Be(expectedMember.GuildId.Value);
        }