public async Task PostNewMessagesCallsTheRepositoryInsertMethod(
            Mock<IUsernameProvider> usernameProvider,
            Mock<IRepository<ChatMessageDataModel>> messageRepository,
            string hubId,
            string channelId,
            string username,
            NewMessageModel newMessage,
            ChatMessageDataModel createdMessage)
        {
            AutoMapper.Mapper.CreateMap<ChatMessage, ChatMessageDataModel>();

            usernameProvider.Setup(p => p.GetUsername()).Returns(Task.FromResult(username));
            messageRepository.Setup(r => r.Insert(It.IsAny<ChatMessageDataModel>())).Returns(Task.FromResult(createdMessage));

            var controllerUnderTest = new MessagesController(usernameProvider.Object, messageRepository.Object);

            await controllerUnderTest.PostNewMessage(hubId, channelId, newMessage);

            var expectedMessageParameter = new ChatMessage(username, channelId, newMessage.Message, DateTime.Now);
            
            messageRepository.Verify(mock => mock.Insert(It.Is<ChatMessageDataModel>(parameter =>
                parameter.ChannelId == channelId && 
                parameter.Message == newMessage.Message &&
                parameter.Username == username
            )), Times.Once());
        }
        public async Task GetPagedMessagesForChannelCallsCorrectRepositoryMethod(
            Mock<IUsernameProvider> usernameProvider,    
            Mock<IRepository<ChatMessageDataModel>> messageRepository,
            string hubId,
            string channelId,
            string username,
            IPagedList<ChatMessageDataModel> messages)
        {

            messageRepository
                .Setup(r => r.GetPaged(1, 100, It.IsAny<Func<IEnumerable<ChatMessageDataModel>, IEnumerable<ChatMessageDataModel>>>()))
                .Returns(Task.FromResult(messages.ToPagedList(1, 100)));

            usernameProvider.Setup(p => p.GetUsername()).Returns(Task.FromResult(username));

            var controllerUnderTest = new MessagesController(usernameProvider.Object, messageRepository.Object);

            await controllerUnderTest.GetPagedMessagesForChannel(hubId, channelId, 1, 100);

            messageRepository.Verify(mock => mock.GetPaged(1, 100, It.IsAny<Func<IEnumerable<ChatMessageDataModel>, IEnumerable<ChatMessageDataModel>>>()), Times.Once());
        }