Example #1
0
        public void Handler_ReturnsNullUser_WhenNotFound_ByUserLoginInfo()
        {
            const string loginProvider      = "loginProvider";
            var          providerKey        = Guid.NewGuid().ToString();
            var          remoteMembershipId = new RemoteMembershipId
            {
                LoginProvider = loginProvider,
                ProviderKey   = Guid.NewGuid().ToString(),
            };
            var remoteMembership = new ProxiedRemoteMembership(remoteMembershipId);
            var user             = new User();

            user.RemoteMemberships.Add(remoteMembership);
            var data = new[] { user }.AsQueryable();
            var query     = new UserBy(new UserLoginInfo(loginProvider, providerKey));
            var dbSet     = new Mock <DbSet <User> >(MockBehavior.Strict).SetupDataAsync(data);
            var entities  = new Mock <IReadEntities>(MockBehavior.Strict);
            var entitySet = new EntitySet <User>(dbSet.Object, entities.Object);

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

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

            result.ShouldBeNull();
            entities.Verify(x => x.Query <User>(), Times.Once);
        }
Example #2
0
        public void CompositeId_GetHashCode_IsBasedOnAllComponents()
        {
            var id = new RemoteMembershipId
            {
                LoginProvider = "loginProvider",
                ProviderKey   = "providerKey",
            };

            id.GetHashCode().ShouldEqual(id.LoginProvider.GetHashCode() ^ id.ProviderKey.GetHashCode());
        }
Example #3
0
        public void CompositeId_GetHashCode_ReturnsZero_WhenAnyComponentIsNull(string loginProvider, string providerKey)
        {
            var id = new RemoteMembershipId
            {
                LoginProvider = loginProvider,
                ProviderKey   = providerKey,
            };

            id.GetHashCode().ShouldEqual(0);
        }
Example #4
0
        public void CompositeId_Equals_ReturnsTrue_WhenReferenceEqualsOther()
        {
            var id = new RemoteMembershipId
            {
                LoginProvider = "loginProvider",
                ProviderKey   = "providerKey",
            };

            id.Equals(id).ShouldBeTrue();
            id.Equals(id as object).ShouldBeTrue();
        }
Example #5
0
        public void CompositeId_Equals_ReturnsFalse_WhenOtherIsNull()
        {
            var id = new RemoteMembershipId
            {
                LoginProvider = "loginProvider",
                ProviderKey   = "providerKey",
            };

            id.Equals(null).ShouldBeFalse();
            id.Equals(null as object).ShouldBeFalse();
        }
Example #6
0
        public void CompositeId_Equals_ReturnsFalse_WhenAnyComponentIsNull(string loginProvider1, string providerKey1, string loginProvider2, string providerKey2)
        {
            var id1 = new RemoteMembershipId
            {
                LoginProvider = loginProvider1,
                ProviderKey   = providerKey1,
            };
            var id2 = new RemoteMembershipId
            {
                LoginProvider = loginProvider2,
                ProviderKey   = providerKey2,
            };

            id1.Equals(id2).ShouldBeFalse();
            id1.Equals(id2 as object).ShouldBeFalse();
            id2.Equals(id1).ShouldBeFalse();
            id2.Equals(id1 as object).ShouldBeFalse();
        }