Exemplo n.º 1
0
        private async Task <ActionResult <IEnumerable <Message> > > GetMessagesBySenderIdAsyncActualAsync()
        {
            var messages = GetMessageList();
            var mockDifiMessageRepository = new Mock <IDifiMessageRepository>();
            var difiList = new List <DifiMessage> {
                messages.ElementAt(0).DifiMessage, messages.ElementAt(1).DifiMessage
            };

            mockDifiMessageRepository.Setup(repository => repository.GetMessagesBySenderIdAsync("989778471", "922308055")).ReturnsAsync(difiList);

            var mockElementsMessageRepisitory = new Mock <IElementsMessageRepository>();
            var elementsList = new List <ElementsMessage> {
                messages.ElementAt(0).ElementsMessage, messages.ElementAt(1).ElementsMessage
            };

            mockElementsMessageRepisitory.Setup(repository => repository.GetElementsMessagesBySenderIdAsync("989778471", "922308055")).ReturnsAsync(elementsList);

            var mockMessageMergeService = new Mock <IMessageMergeService>();

            mockMessageMergeService.Setup(service => service.MergeMessagesListsInAsync("989778471", difiList, elementsList)).ReturnsAsync(messages);

            var messageController = new MessagesController();
            var actual            = await messageController.GetMessagesBySenderIdAsync("989778471", "922308055", mockMessageMergeService.Object, mockDifiMessageRepository.Object, mockElementsMessageRepisitory.Object);

            return(actual);
        }