Exemplo n.º 1
0
        public void CreateUserShouldDelegateToEntityManagerWithCorrectCollectionNameAndUser()
        {
            var user = new UsergridUser();

            _client.CreateUser(user);

            _entityManager.Received(1).CreateEntity("users", user);
        }
Exemplo n.º 2
0
		public UsergridActivity(UsergridUser user, UsergridImage image = null){
			Actor = new UsergridActor {
				DisplayName = user.Name,
				Email = user.Email,
				Image = image,
				UserName = user.UserName,
				Uuid = user.Uuid
			};
		}
 public UsergridActivity(UsergridUser user, UsergridImage image = null)
 {
     Actor = new UsergridActor {
         DisplayName = user.Name,
         Email       = user.Email,
         Image       = image,
         UserName    = user.UserName,
         Uuid        = user.Uuid
     };
 }
Exemplo n.º 4
0
        public void UpdateUserShouldPassOnTheException()
        {
            var user = new UsergridUser {UserName = "******"};

            _entityManager
                .When(m => m.UpdateEntity("users", user.UserName, user))
                .Do(m => { throw new UsergridException(new UsergridError {Description = "Exception message"}); });

            _client.UpdateUser(user);
        }
Exemplo n.º 5
0
        public void UpdateUserShouldDelegateToEntityManagerrWithCorrectCollectionNameAndUserNameAsTheIdentifier()
        {
            var user = new UsergridUser {UserName = "******"};

            _client.UpdateUser(user);

            _entityManager.Received(1).UpdateEntity("users", user.UserName, user);
        }
Exemplo n.º 6
0
        public void GetUserShouldReturnUsergridUser()
        {
            var usergridUser = new UsergridUser();
            _entityManager.GetEntity<UsergridUser>("users", "identifier").Returns((x) => usergridUser);

            var returnedUser = _client.GetUser<UsergridUser>("identifier");

            Assert.AreEqual(usergridUser, returnedUser);
        }
Exemplo n.º 7
0
        public void ShouldFollowUserViaConnections()
        {
            IClient client = InitializeClientAndLogin(AuthType.Organization);
            DeleteUserIfExists(client, "user1");
            DeleteUserIfExists(client, "user2");
            
            UsergridUser user1 = new UsergridUser { UserName = "******", Email = "*****@*****.**" };
            client.CreateUser(user1);
            UsergridUser user2 = new UsergridUser { UserName = "******", Email = "*****@*****.**" };
            client.CreateUser(user2);
            
            var conn = new Connection();
            conn.ConnectorIdentifier = "user1";
            conn.ConnectorCollectionName = "users";
            conn.ConnecteeIdentifier = "user2";
            conn.ConnecteeCollectionName = "users";
            conn.ConnectionName = "following";
            
            client.CreateConnection(conn);

            //verify the connections
            var user1Uuid = client.GetEntities<UsergridUser>("users", limit: 1, query: "select * where username='******'").First().Uuid;
            var user2Uuid = client.GetEntities<UsergridUser>("users", limit: 1, query: "select * where username='******'").First().Uuid;

            //user1 should be following user2
            IList<UsergridEntity> followingConnections = client.GetConnections(new Connection()
            {
                ConnectorCollectionName = "users",
                ConnectorIdentifier = "user1",
                ConnectionName = "following"
            });

            Assert.AreEqual(1, followingConnections.Count);
            Assert.AreEqual(user2Uuid, followingConnections[0].Uuid);

            //also, user1 should be in the followers connection of user2
            IList<UsergridEntity> followersConnections = client.GetConnections(new Connection()
            {
                ConnectorCollectionName = "users",
                ConnectorIdentifier = "user2",
                ConnectionName = "followers"
            });

            Assert.AreEqual(1, followersConnections.Count);
            Assert.AreEqual(user1Uuid, followersConnections[0].Uuid);
        }