public async Task StuffController_Read_ShouldReturn_Null() { // Arrange var mockUserRepo = Mock.Of <IStuffRepo>(); var controller = new StuffController(mockUserRepo); // Act IActionResult actionResult = await controller.Read("1"); // Assert var okResult = Assert.IsType <OkObjectResult>(actionResult); var contentResult = okResult.Value; StuffModel expected = null; var actual = contentResult; Assert.Equal(expected, actual); }
public async Task StuffController_Read_ShouldReturn_Ok() { // Arrange var mockStuffRepo = Mock.Of <IStuffRepo>(x => x.ReadAsync("1") == Task.FromResult(TestDatum)); var controller = new StuffController(mockStuffRepo); // Act IActionResult actionResult = await controller.Read("1"); // Assert var okResult = Assert.IsType <OkObjectResult>(actionResult); var contentResult = Assert.IsType <DatumModel>(okResult.Value); var expected = TestDatum.Id; var actual = contentResult.Id; Assert.Equal(expected, actual); }