public void CanGetChatMessagesFromExternalChatProviderApi() { var clientRepository = new Mock <IRepository <Client> >(); var chatRepository = new Mock <IRepository <Contact> >(); var contactService = new Mock <IContactService>(); var restClient = new Mock <IRestClient>(); var userManager = new Mock <IIdentityMembershipProvider>(); var contactAutoRating = new Mock <IContactAutoRating>(); var pageNumber = 1; var dateFrom = new DateTime(2014 - 01 - 01); var controller = new ChatController( chatRepository.Object, clientRepository.Object, contactService.Object, new ServerTime(), restClient.Object, userManager.Object, contactAutoRating.Object); var responseMessage = new RestResponse(); responseMessage.Content = "{\"chats\":[{\"text\":\"some text\"}]}"; restClient.Setup(rc => rc.Execute(It.IsAny <RestRequest>())).Returns(responseMessage); var result = controller.ChatMessages(pageNumber, dateFrom) as ContentResult; restClient.Verify(rc => rc.Execute(It.Is <RestRequest>(rq => rq.Parameters.Any())), Times.Once); Assert.AreEqual("{\"chats\":[{\"text\":\"some text\"}]}", result.Content); }