public void Should_Fail_By_Empty_Name() { // arrange var command = PatchMemberCommandFake.ChangeMemberNameInvalidByEmptyName().Generate(); var memberRepository = MemberRepositoryMockBuilder.Create().Build(); var sut = new ChangeMemberNameValidator(memberRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.AssertErrorsCount(1); }
public void Should_Fail_By_Member_NotFound() { // arrange var command = PatchMemberCommandFake.ChangeMemberNameValid().Generate(); var memberRepository = MemberRepositoryMockBuilder.Create() .ExistsWithId(false, command.Id) .CanChangeName(true, command.Id, command.Name).Build(); var sut = new ChangeMemberNameValidator(memberRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.AssertErrorsCount(1); }
public void Should_Succeed() { // arrange var command = PatchMemberCommandFake.ChangeMemberNameValid().Generate(); var memberRepository = MemberRepositoryMockBuilder.Create() .ExistsWithId(true, command.Id) .CanChangeName(true, command.Id, command.Name).Build(); var sut = new ChangeMemberNameValidator(memberRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.Should().NotBeNull() .And.BeOfType <ValidationResult>(); result.IsValid.Should().BeTrue(); }