public async Task Put_CorrectViewModelGiven_ReturnsOkResult() { var viewModel = _fixture.Create <ResultViewModel>(); _commandDispatcherMock.Setup(x => x.DispatchAsync <UpdateResultCommand>(It.IsAny <UpdateResultCommand>())) .Returns(Task.CompletedTask); var result = await _controller.Put(viewModel) as OkResult; Assert.IsNotNull(result); }
public void Put_WhenCorrectViewModelGiven_ShouldReturnJsonViewModel() { var resultId = 1; var resultModel = new Result { Id = resultId, Text = "Text1" }; _mockRepo.Setup(x => x.UpdateResult(It.Is <Result>(r => r.Id == resultId))).Returns(Task.FromResult(resultModel)); var result = _sut.Put(resultModel.Adapt <ResultViewModel>()).Result as JsonResult; Assert.IsNotNull(result); Assert.AreEqual(result.GetObjectFromJsonResult <ResultViewModel>().Text, resultModel.Text); Assert.AreEqual(result.GetObjectFromJsonResult <ResultViewModel>().Id, resultModel.Id); }