Esempio n. 1
0
        private async Task <ActionResult <IEnumerable <Message> > > GetMessagesByReceiverIdAsyncActualAsync()
        {
            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.GetMessagesByReceiverIdAsync("922308055", "989778471")).ReturnsAsync(difiList);

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

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

            var mockMessageMergeService = new Mock <IMessageMergeService>();

            mockMessageMergeService.Setup(service => service.MergeMessagesListsOutAsync("922308055", elementsList, difiList)).ReturnsAsync(messages);

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

            return(actual);
        }