public void Should_Fail_Cancel_By_Empty_Id() { // arrange var command = PatchInviteCommandFake.CancelInvalidByEmptyId().Generate(); var inviteRepository = InviteRepositoryMockBuilder.Create().Build(); var sut = new CancelInviteValidator(inviteRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.AssertErrorsCount(1); }
public void Should_Fail_Cancel_By_Invite_NotPending() { // arrange var invite = InviteFake.ValidWithStatus(InviteStatuses.Canceled).Generate(); var command = PatchInviteCommandFake.CancelValid(invite.Id).Generate(); var inviteRepository = InviteRepositoryMockBuilder.Create().GetByIdSuccess(output: invite).Build(); var sut = new CancelInviteValidator(inviteRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.AssertErrorsCount(1); }
public void Should_Succeed_Cancel() { // arrange var invite = InviteFake.ValidWithStatus().Generate(); var command = PatchInviteCommandFake.CancelValid(invite.Id).Generate(); var inviteRepository = InviteRepositoryMockBuilder.Create().GetByIdSuccess(output: invite).Build(); var sut = new CancelInviteValidator(inviteRepository) { CascadeMode = FluentValidation.CascadeMode.Stop }; // act var result = sut.Validate(command); // assert result.Should().NotBeNull().And.BeOfType <ValidationResult>(); result.IsValid.Should().BeTrue(); }