public void Query_Ctor_SetsProperties(EmailVerificationPurpose purpose)
 {
     var token = FakeData.String();
     var ticket = FakeData.String();
     var query = new EmailVerificationTokenIsValid(token, ticket, purpose);
     query.Token.ShouldEqual(token);
     query.Ticket.ShouldEqual(ticket);
     query.Purpose.ShouldEqual(purpose);
 }
        public void Handler_ReturnsFalse_WhenTokenIsEmpty(EmailVerificationPurpose purpose, string token)
        {
            string ticket = FakeData.String();
            var command = new EmailVerificationTokenIsValid(token, ticket, purpose);
            var userStore = new Mock<IUserStore<UserTicket, string>>(MockBehavior.Strict);
            var userManager = new UserManager<UserTicket, string>(userStore.Object);
            var tokenProvider = new Mock<IUserTokenProvider<UserTicket, string>>(MockBehavior.Strict);
            Expression<Func<IUserTokenProvider<UserTicket, string>, Task<bool>>> expectedMethod =
                x => x.ValidateAsync(purpose.ToString(), token, userManager,
                    It.Is<UserTicket>(y => y.UserName == ticket));
            tokenProvider.Setup(expectedMethod)
                .Returns(Task.FromResult(true));
            userManager.UserTokenProvider = tokenProvider.Object;
            var handler = new HandleEmailVerificationTokenIsValidQuery(userManager);

            bool result = handler.Handle(command).Result;

            result.ShouldBeFalse();
            tokenProvider.Verify(expectedMethod, Times.Never);
        }