示例#1
0
        public async Task AdminAggregateUtilizationAsyncTest_WhenPartnerIdandFilter_ReturnsSentMessageReport()
        {
            var mockLogRepository     = new Mock <ILogRepository>();
            var mockContactRepository = new Mock <IContactRepository>();

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

            var chatUser = EntityModellers.GetChatUserEntity();

            var employeeIds = new List <int>()
            {
                1, 2, 3
            };
            var chatUserList = new List <ChatUser> {
                chatUser
            };
            var partnerId = 2;
            var teamId    = _rnd.Next(111, 1000);
            var filter    = EntityModellers.GetAggregateUtilizationReportRequestModel();
            var log       = new LogEntity
            {
                RecipientId   = 1,
                RecepientName = "User1",
                ThreadId      = Guid.NewGuid(),
                SenderId      = 1,
                MessageId     = Guid.NewGuid(),
                Message       = "message",
                CreatedAt     = Convert.ToDateTime("3/6/2019"),
                IsImportant   = true,
                IsArchived    = true,
                IsRead        = true,
                ReadAt        = DateTime.Now,
                ArchivedAt    = DateTime.Now,
                TeamId        = teamId
            };
            var logs1 = new List <LogEntity> {
                log
            };
            var aggregateReport  = EntityModellers.GetAggregateUtilizationReportResponseModel();
            var aggregateReports = new List <AggregateUtilizationReportResponseModel> {
                aggregateReport
            };
            var expected = aggregateReports;

            mockContactRepository.Setup(x => x.GetChatUsersAsync(filter.EmployeeIds, partnerId)).ReturnsAsync(chatUserList);
            // mockLogRepository.Setup(x => x.GetAllAsync()).ReturnsAsync(logs);
            mockLogRepository.Setup(x => x.GetByDatesAsync(filter, employeeIds)).ReturnsAsync(logs1);
            mapper.Setup(x => x.Map <IEnumerable <LogEntity>, IEnumerable <AggregateUtilizationReportResponseModel> >(logs1)).Returns(expected);

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

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