Пример #1
0
        public ActionResult <dynamic> BlockUser(UserCache cache)
        {
            string message = null;

            if (blocks.BlockUser(cache.user_token, cache.opposide_public_token, cache.blocked_reason, ref message))
            {
                return(new { success = true, message = "Block user - successed." });
            }
            return(Return500Error(message));
        }
Пример #2
0
        public void BlockUser()
        {
            User first           = CreateMockingUser();
            User second          = CreateMockingUser();
            bool blocked         = blocks.BlockUser(first.UserToken, second.UserPublicToken, "Test block", ref message);
            bool nonDoubleBlocks = blocks.BlockUser(first.UserToken, second.UserPublicToken, "Test block", ref message);

            Assert.AreEqual(blocked, true);
            Assert.AreEqual(nonDoubleBlocks, false);
        }
Пример #3
0
        public void GetUserByGenderWithBlocked()
        {
            DeleteUsers();
            User     first    = CreateMockingUser();
            User     second   = CreateMockingUser();
            User     third    = CreateMockingUser();
            Profiles profiles = new Profiles(context);

            first.Profile = profiles.CreateIfNotExistProfile(first.UserId);
            profiles.UpdateGender(first.Profile, "1", ref message);
            Blocks blocks = new Blocks(users, context);

            blocks.BlockUser(first.UserToken, third.UserPublicToken, "Test block.", ref message);
            var successWithBlocked = users.GetUsersByGender(first.UserId, true, 0, 1);

            Assert.AreEqual(successWithBlocked[0].user_id, second.UserId);
        }
Пример #4
0
        public void GetReciprocalUsersWithBlocked()
        {
            DeleteUsers();
            User     firstUser  = CreateMockingUser();
            User     secondUser = CreateMockingUser();
            User     thirdUser  = CreateMockingUser();
            Profiles profiles   = new Profiles(context);

            firstUser.Profile = profiles.CreateIfNotExistProfile(firstUser.UserId);
            profiles.UpdateGender(firstUser.Profile, "1", ref message);
            users.CreateLike(thirdUser.UserId, firstUser.UserId);
            users.CreateLike(secondUser.UserId, firstUser.UserId);
            Blocks blocks = new Blocks(users, context);

            blocks.BlockUser(firstUser.UserToken, secondUser.UserPublicToken, "Test block.", ref message);
            var success = users.GetReciprocalUsers(firstUser.UserId, true, 0, 1);

            Assert.AreEqual(success[0].user_id, thirdUser.UserId);
        }
Пример #5
0
        public void GetUsers()
        {
            DeleteUsers();
            User   first   = CreateMockingUser();
            User   second  = CreateMockingUser();
            User   third   = CreateMockingUser();
            var    success = users.GetUsers(first.UserId, 0, 2);
            Blocks blocks  = new Blocks(users, context);

            blocks.BlockUser(first.UserToken, third.UserPublicToken, "Test block.", ref message);
            var successWithBlocked     = users.GetUsers(first.UserId, 0, 2);
            var anotherUserWithBlocked = users.GetUsers(third.UserId, 0, 2);

            Assert.AreEqual(success[0].user_id, third.UserId);
            Assert.AreEqual(success[1].user_id, second.UserId);
            Assert.AreEqual(successWithBlocked[0].user_id, second.UserId);
            Assert.AreEqual(anotherUserWithBlocked[0].user_id, second.UserId);
            Assert.AreEqual(anotherUserWithBlocked[1].user_id, first.UserId);
        }
Пример #6
0
        public void GetChatsByGenderWithBlocked()
        {
            DeleteUsers();
            Profiles profiles   = new Profiles(context);
            Blocks   blocks     = new Blocks(new Users(context, new Validator()), context);
            User     firstUser  = CreateMockingUser();
            User     secondUser = CreateMockingUser();
            User     thirdUser  = CreateMockingUser();
            Chatroom firstRoom  = chats.CreateChat(firstUser.UserToken, secondUser.UserPublicToken, ref message);
            Chatroom secondRoom = chats.CreateChat(firstUser.UserToken, thirdUser.UserPublicToken, ref message);

            profiles.UpdateGender(firstUser.Profile, "1", ref message);
            blocks.BlockUser(firstUser.UserToken, thirdUser.UserPublicToken, "Test block.", ref message);
            var successWithBlocked = chats.GetChatsByGender(firstUser.UserId, true, 0, 1);

            Assert.AreEqual(successWithBlocked[0].user.user_id, secondUser.UserId);
            Assert.AreEqual(successWithBlocked[0].chat.chat_id, firstRoom.ChatId);
            Assert.AreEqual(successWithBlocked[0].last_message, null);
        }
Пример #7
0
        public void GetChatsWithBlocking()
        {
            DeleteUsers();
            User   firstUser     = CreateMockingUser();
            User   secondUser    = CreateMockingUser();
            User   thirdUser     = CreateMockingUser();
            var    firstRoom     = chats.CreateChat(firstUser.UserToken, secondUser.UserPublicToken, ref message);
            var    secondRoom    = chats.CreateChat(firstUser.UserToken, thirdUser.UserPublicToken, ref message);
            var    firstMessage  = chats.CreateMessage("Testing text.", firstUser.UserToken, firstRoom.ChatToken, ref message);
            var    secondMessage = chats.CreateMessage("Testing text.", firstUser.UserToken, secondRoom.ChatToken, ref message);
            Blocks blocks        = new Blocks(new Users(context, new Validator()), context);

            blocks.BlockUser(firstUser.UserToken, secondUser.UserPublicToken, "Test block.", ref message);
            ChatCache cache = new ChatCache();

            cache.user_token = firstUser.UserToken;
            var successWithBlocking = chats.GetChats(firstUser.UserId, 0, 2);

            Assert.AreEqual(successWithBlocking[0].user.user_id, thirdUser.UserId);
            Assert.AreEqual(successWithBlocking[0].chat.chat_id, secondRoom.ChatId);
            Assert.AreEqual(successWithBlocking[0].last_message.message_id, secondMessage.MessageId);
        }