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 Handler_ReturnsNonNullLocalMembership_WhenFound_ByUserId() { var userId = FakeData.Id(); var user = new ProxiedUser(userId); var data = new[] { new LocalMembership { User = user, PasswordHash = "password hash", }, }.AsQueryable(); var query = new LocalMembershipByUser(userId); 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 HandleLocalMembershipByUserQuery(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 Handler_ReturnsNonNullLocalMembership_WhenFound_ByUserLoginInfo() { var loginProvider = Guid.NewGuid().ToString(); var providerKey = Guid.NewGuid().ToString(); var userLoginInfo = new UserLoginInfo(loginProvider, providerKey); var user = new User(); user.RemoteMemberships.Add(new ProxiedRemoteMembership( loginProvider, providerKey)); var data = new[] { new LocalMembership { User = user, PasswordHash = "password hash", }, }.AsQueryable(); var query = new LocalMembershipByUser(userLoginInfo); 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 HandleLocalMembershipByUserQuery(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); }