public void ReturnsCorrectChatData() { // Given var userChatResponse = new UserChatResponse { ChatId = 1, CollocutorId = 2, CollocutorName = "John", LastMessage = "Hello", LastMessageTime = DateTime.Now }; _chatServiceMock .Setup(_ => _.GetUserChats(USER_ID)) .Returns(new List <UserChatResponse> { userChatResponse }) .Verifiable(); // When var result = _chatApiController.GetChatData(); // Then Mock.Verify(_chatServiceMock); Mock.Verify(_userRepositoryMock); Mock.Verify(_chatServiceMock); result.Should().BeOfType <ObjectResult>(); var objectResult = (ObjectResult)result; objectResult.Value.Should().BeOfType <List <UserChatResponse> >(); ((List <UserChatResponse>)objectResult.Value).Should().Contain(userChatResponse); }
public void ReturnsCorrectChatId() { // Given var userChatResponse = new UserChatResponse { ChatId = 1, CollocutorId = 2, CollocutorName = "John", LastMessage = "Hello", LastMessageTime = DateTime.Now }; _chatServiceMock .Setup(_ => _.GetUserChats(USER_ID)) .Returns(new List <UserChatResponse> { userChatResponse }) .Verifiable(); // When var result = _chatController.ChatView(null); // Then Mock.Verify(_userInfoProviderMock); Mock.Verify(_userRepositoryMock); Mock.Verify(_chatServiceMock); result.Should().BeOfType <ViewResult>(); var viewResult = (ViewResult)result; viewResult.Model.Should().BeEquivalentTo(new ChatViewModel { UserId = USER_ID, UserChats = new List <UserChatResponse> { userChatResponse }, SelectedChatId = userChatResponse.ChatId }); }