public void Handler_ReturnsNonNullLocalMembership_WhenFound_ByUserName()
        {
            var emailAddress = FakeData.Email();
            var user         = new User();

            user.EmailAddresses.Add(new EmailAddress
            {
                IsVerified = true,
                Value      = emailAddress,
            });
            var data = new[]
            {
                new LocalMembership
                {
                    User         = user,
                    PasswordHash = "password hash",
                },
            }.AsQueryable();
            var query     = new LocalMembershipByVerifiedEmail(emailAddress);
            var dbSet     = new Mock <DbSet <LocalMembership> >(MockBehavior.Strict).SetupDataAsync(data);
            var entities  = new Mock <IReadEntities>(MockBehavior.Strict);
            var entitySet = new EntitySet <LocalMembership>(dbSet.Object, entities.Object);

            entities.Setup(x => x.Query <LocalMembership>()).Returns(entitySet);
            var handler = new HandleLocalMembershipByVerifiedEmailQuery(entities.Object);

            LocalMembership result = handler.Handle(query).Result;

            result.ShouldNotBeNull();
            result.User.ShouldEqual(user);
            result.PasswordHash.ShouldEqual("password hash");
            entities.Verify(x => x.Query <LocalMembership>(), Times.Once);
        }
        public void Query_StringCtor_SetsEmailAddressProperty()
        {
            var emailAddress = FakeData.Email();
            var query        = new LocalMembershipByVerifiedEmail(emailAddress);

            query.EmailAddress.ShouldEqual(emailAddress);
        }
Пример #3
0
        public void Handler_ReturnsNullLocalMembership_WhenNotFound_ByVerifiedEmail()
        {
            var emailAddress = string.Format("{0}@domain.tld", Guid.NewGuid());
            var user         = new User();

            user.EmailAddresses.Add(new EmailAddress
            {
                IsVerified = false,
                Value      = emailAddress,
            });
            var data = new[]
            {
                new LocalMembership {
                    User = user,
                },
            }.AsQueryable();
            var query     = new LocalMembershipByVerifiedEmail(emailAddress);
            var dbSet     = new Mock <DbSet <LocalMembership> >(MockBehavior.Strict).SetupDataAsync(data);
            var entities  = new Mock <IReadEntities>(MockBehavior.Strict);
            var entitySet = new EntitySet <LocalMembership>(dbSet.Object, entities.Object);

            entities.Setup(x => x.Query <LocalMembership>()).Returns(entitySet);
            var handler = new HandleLocalMembershipByVerifiedEmailQuery(entities.Object);

            LocalMembership result = handler.Handle(query).Result;

            result.ShouldBeNull();
            entities.Verify(x => x.Query <LocalMembership>(), Times.Once);
        }
Пример #4
0
        public void Query_StringCtor_SetsEmailAddressProperty()
        {
            var emailAddress = string.Format("{0}@domain.tld", Guid.NewGuid());
            var query        = new LocalMembershipByVerifiedEmail(emailAddress);

            query.EmailAddress.ShouldEqual(emailAddress);
        }
Пример #5
0
        public Task <LocalMembership> Handle(LocalMembershipByVerifiedEmail query)
        {
            var queryable = _entities.Query <LocalMembership>().EagerLoad(query.EagerLoad);

            return(queryable.ByVerifiedEmailAsync(query.EmailAddress));
        }