コード例 #1
0
ファイル: SecurityStoreTests.cs プロジェクト: phobos04/tripod
        public void UserLoginStoreInterface_RemoveLoginAsync_DelegatesToUserCollectionProperty(string provider, string key, bool expectRemove)
        {
            var instance = new SecurityStore(null) as IUserLoginStore<User, int>;
            var user = new FakeUser(6);
            user.RemoteMemberships.Add(new RemoteMembership
            {
                UserId = user.Id,
                Id = { LoginProvider = "provider1", ProviderKey = "key1" }
            });
            var login = new UserLoginInfo(provider, key);
            instance.RemoveLoginAsync(user, login).Wait();

            user.RemoteMemberships.Any(x => x.LoginProvider == provider && x.ProviderKey == provider).ShouldEqual(false);
            user.RemoteMemberships.Any().ShouldEqual(!expectRemove);
        }
コード例 #2
0
ファイル: SecurityStoreTests.cs プロジェクト: phobos04/tripod
        public void UserLoginStoreInterface_GetLoginsAsync_DelegatesToUserCollectionProperty()
        {
            var instance = new SecurityStore(null) as IUserLoginStore<User, int>;
            var user = new FakeUser(6);
            user.RemoteMemberships.Add(new RemoteMembership
            {
                UserId = user.Id,
                Id = { LoginProvider = "provider1", ProviderKey = "key1" }
            });
            user.RemoteMemberships.Add(new RemoteMembership
            {
                UserId = user.Id,
                Id = { LoginProvider = "provider2", ProviderKey = "key2" }
            });
            var result = instance.GetLoginsAsync(user).Result;

            result.ShouldNotBeNull();
            result.Count.ShouldEqual(2);
            result.Any(x => x.LoginProvider == user.RemoteMemberships.ElementAt(0).LoginProvider
                && x.ProviderKey == user.RemoteMemberships.ElementAt(0).ProviderKey).ShouldBeTrue();
            result.Any(x => x.LoginProvider == user.RemoteMemberships.ElementAt(1).LoginProvider
                && x.ProviderKey == user.RemoteMemberships.ElementAt(1).ProviderKey).ShouldBeTrue();
        }
コード例 #3
0
ファイル: SecurityStoreTests.cs プロジェクト: phobos04/tripod
 public void UserLoginStoreInterface_AddLoginAsync_DelegatesToDataDependency()
 {
     var entities = new Mock<IWriteEntities>(MockBehavior.Strict);
     var instance = new SecurityStore(entities.Object) as IUserLoginStore<User, int>;
     var user = new FakeUser(6);
     var login = new UserLoginInfo(Guid.NewGuid().ToString(), Guid.NewGuid().ToString());
     Expression<Func<RemoteMembership, bool>> expectedEntity = x => x.UserId == user.Id
         && x.LoginProvider == login.LoginProvider && x.ProviderKey == login.ProviderKey;
     entities.Setup(x => x.Create(It.Is(expectedEntity)));
     instance.AddLoginAsync(user, login);
     entities.Verify(x => x.Create(It.Is(expectedEntity)), Times.Once);
 }