Esempio n. 1
0
        public void Should_Fail_By_Empty_Id()
        {
            // arrange
            var command          = PatchMemberCommandFake.DemoteMemberInvalidByEmptyId().Generate();
            var memberRepository = MemberRepositoryMockBuilder.Create().Build();
            var sut = new DemoteMemberValidator(memberRepository)
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

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

            // assert
            result.AssertErrorsCount(1);
        }
Esempio n. 2
0
        public void Should_Fail_By_Member_NotGuildLeader()
        {
            // arrange
            var member           = MemberFake.GuildMember().Generate();
            var command          = PatchMemberCommandFake.DemoteMemberValid(member.Id).Generate();
            var memberRepository = MemberRepositoryMockBuilder.Create()
                                   .GetByIdSuccess(member.Id, member).Build();
            var sut = new DemoteMemberValidator(memberRepository)
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

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

            // assert
            result.AssertErrorsCount(1);
        }
Esempio n. 3
0
        public void Should_Succeed()
        {
            // arrange
            var member           = MemberFake.GuildLeader().Generate();
            var command          = PatchMemberCommandFake.DemoteMemberValid(member.Id).Generate();
            var memberRepository = MemberRepositoryMockBuilder.Create()
                                   .GetByIdSuccess(member.Id, member).Build();
            var sut = new DemoteMemberValidator(memberRepository)
            {
                CascadeMode = FluentValidation.CascadeMode.Stop
            };

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

            // assert
            result.Should().NotBeNull().And.BeOfType <ValidationResult>();
            result.IsValid.Should().BeTrue();
        }