Exemplo n.º 1
0
        public async Task GetAdminChatLogAsyncTest_WhenPartnerId_ReturnsChatLogs()
        {
            var mockLogRepository     = new Mock <ILogRepository>();
            var mockContactRepository = new Mock <IContactRepository>();

            var mockLogManager = new Mock <ILogManager>();
            var mapper         = new Mock <IMapper>();

            var chatUserList = new List <int> {
                1, 2, 3
            };
            var userId    = _rnd.Next(111, 1000);
            var partnerId = _rnd.Next(111, 1000);
            var senderId  = _rnd.Next(111, 1000);
            var teamId    = _rnd.Next(111, 1000);
            var log       = EntityModellers.GetLogEntity();
            var logs      = new List <LogEntity> {
                log
            };
            var chatResponse = EntityModellers.GetChatLogResponse();
            var expected     = new List <ChatLogResponse> {
                chatResponse
            };

            mockContactRepository.Setup(x => x.GetChatUsersForPartner(partnerId)).Returns(chatUserList);
            mockLogRepository.Setup(x => x.GetAllAsync()).ReturnsAsync(logs);
            mapper.Setup(x => x.Map <IEnumerable <LogEntity>, IEnumerable <ChatLogResponse> >(logs)).Returns(expected);

            var logManager = new LogManager(mockContactRepository.Object, mockLogRepository.Object, mapper.Object);
            var actual     = await logManager.AdminChatLogAsync(partnerId);

            Assert.Equal(expected, actual, new LogicEqualityComparer <ChatLogResponse>());
            mockLogRepository.VerifyAll();
            mockContactRepository.VerifyAll();
        }