コード例 #1
0
        public void IsValid_WhenTicket_IsEmpty(string ticket)
        {
            var queries = new Mock <IProcessQueries>(MockBehavior.Strict);
            var command = new FakeMustNotBeRedeemedVerifyEmailTicketCommand {
                Ticket = ticket,
            };
            var validator = new FakeMustNotBeRedeemedVerifyEmailTicketValidator(queries.Object);

            var result = validator.Validate(command);

            result.IsValid.ShouldBeTrue();
            queries.Verify(x => x.Execute(It.IsAny <EmailVerificationBy>()), Times.Never);
            validator.ShouldNotHaveValidationErrorFor(x => x.Ticket, command.Ticket);
            queries.Verify(x => x.Execute(It.IsAny <EmailVerificationBy>()), Times.Never);
        }
コード例 #2
0
        public void IsValid_WhenEmailVerification_IsNotFoundByTicket()
        {
            var ticket  = FakeData.String();
            var queries = new Mock <IProcessQueries>(MockBehavior.Strict);
            var command = new FakeMustNotBeRedeemedVerifyEmailTicketCommand {
                Ticket = ticket,
            };
            Expression <Func <EmailVerificationBy, bool> > expectedQuery = x => x.Ticket == ticket;

            queries.Setup(x => x.Execute(It.Is(expectedQuery))).Returns(Task.FromResult(null as EmailVerification));
            var validator = new FakeMustNotBeRedeemedVerifyEmailTicketValidator(queries.Object);

            var result = validator.Validate(command);

            result.IsValid.ShouldBeTrue();
            queries.Verify(x => x.Execute(It.Is(expectedQuery)), Times.Once);
            validator.ShouldNotHaveValidationErrorFor(x => x.Ticket, command.Ticket);
            queries.Verify(x => x.Execute(It.Is(expectedQuery)), Times.Exactly(2));
        }