Пример #1
0
        public void TestCreateGroupChat()
        {
            mockConversationRepository.Setup(x => x.Add(It.IsAny <Conversation>())).Returns(conversation);
            var          chatService        = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            Conversation conversationActual = chatService.CreateGroupChat(conversation);

            Assert.AreEqual(conversationActual, conversation);
        }
Пример #2
0
        public void TestRemoveUserFromGroupChat()
        {
            mockConversationRepository.Setup(x => x.RemoveUserFromGroupChat(It.IsAny <string>(), It.IsAny <string>())).Returns(true);
            var  chatService = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            bool checkRemove = chatService.RemoveUserFromGroupChat("asfas9fdsa8fa7f6sf6as", "asfas9fdsa8fa7f6sf6ass");

            Assert.IsTrue(checkRemove);
        }
Пример #3
0
        public void TestGetById()
        {
            mockConversationRepository.Setup(x => x.GetById(It.IsAny <string>())).Returns(conversation);
            var          chatService        = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            Conversation conversationActual = chatService.GetById("asfas9fdsa8fa7f6sf6as");

            Assert.AreEqual(conversationActual, conversation);
        }
Пример #4
0
        public void TestAddUserToGroupChat()
        {
            mockConversationRepository.Setup(x => x.AddUserToGroupChat(It.IsAny <string>(), It.IsAny <string>())).Returns(user);
            var  chatService = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            User userActual  = chatService.AddUserToGroupChat("asf6af5asf4s4af3afa5f", "asf6af5asf4s4af3afa5f");

            Assert.AreEqual(userActual, user);
        }
Пример #5
0
        public void TestAddToSeenIds()
        {
            mockConversationRepository.Setup(x => x.AddToSeenIds(It.IsAny <string>(), It.IsAny <string>())).Returns(true);
            var  chatService       = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            bool checkAddToSeenIds = chatService.AddToSeenIds("asf6af5asf4s4af3afa5f", "asf6af5asf4s4af3afa5f");

            Assert.IsTrue(checkAddToSeenIds);
        }
Пример #6
0
        public void TestAddMessage()
        {
            mockConversationRepository.Setup(x => x.FindPrivateConversationByReceiverId(It.IsAny <string>())).Returns(conversation);
            mockConversationRepository.Setup(x => x.Update(It.IsAny <Conversation>())).Returns(conversation);
            mockMessageRepository.Setup(x => x.Add(It.IsAny <MessageDetail>())).Returns(messageDetail);
            var           chatService         = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            MessageDetail messageDetailActual = chatService.AddMessage("5d4d0x2613376b00013a898z", messageDetail);

            Assert.AreEqual(messageDetailActual, messageDetail);
        }
Пример #7
0
        public void TestGetByUserId()
        {
            IEnumerable <Conversation> _iEnumerableConversation = listConversations;

            mockConversationRepository.Setup(x => x.GetByUserId(It.IsAny <string>())).Returns(_iEnumerableConversation);
            var chatService = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            IEnumerable <Conversation> ienumableGetByUserId = chatService.GetByUserId("asfas9fdsa8fa7f6sf6as");
            Conversation conversationActual = ienumableGetByUserId.FirstOrDefault();

            Assert.AreEqual(conversationActual.Id, "5d4d0x2613376b00013a8909");
        }
Пример #8
0
        public void TestGetByConversationId()
        {
            IEnumerable <MessageDetail> _iEnumableMessageDetail = listMessageDetails;

            mockConversationRepository.Setup(x => x.GetMessageByConversationId(It.IsAny <string>())).Returns(_iEnumableMessageDetail);
            var chatService = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            IEnumerable <MessageDetail> _iEnumerableGetByConversationId = chatService.GetByConversationId("asfas9fdsa8fa7f6sf6as");
            MessageDetail messageDetailActual = _iEnumerableGetByConversationId.FirstOrDefault();

            Assert.AreEqual(messageDetailActual.Id, "5d4d012613376b00013a892x");
        }
Пример #9
0
        public void TestGetAllMember()
        {
            IEnumerable <User> _iEnumerableUser = listUsers;

            mockConversationRepository.Setup(x => x.GetAllUserInConversation(It.IsAny <string>())).Returns(_iEnumerableUser);
            var chatService = new ChatService.Services.ChatService(mockConversationRepository.Object, mockMessageRepository.Object);
            IEnumerable <User> iEnumerableGetAllMemberActual = chatService.GetAllMember("asfas9fdsa8fa7f6sf6as");
            User userActual = iEnumerableGetAllMemberActual.FirstOrDefault();

            Assert.AreEqual(userActual.Id, "5d4d012613376b00013a8908");
        }