public void JsonResult_ThrowsAssertActualExpectedException_WhenValueNotEqual() { // Arrange var jsonResult = new JsonResult(new { Value = "TestValue" }); // Act & Assert Assert.Throws <AssertActualExpectedException>(() => MvcAssert.JsonResult(jsonResult, new { OtherValue = "TestValue" })); }
public void JsonResult_ThrowsIsTypeException_WhenIActionResultIsNotJsonResult() { // Arrange var mockActionResult = new Mock <IActionResult>(MockBehavior.Strict); // Act & Assert Assert.Throws <IsTypeException>(() => MvcAssert.JsonResult(mockActionResult.Object, new { Value = "TestValue" })); }
public void JsonResult_ReturnJsonResult() { // Arrange var jsonResult = new JsonResult(new { Value = "TestValue" }); // Act & Assert var result = Assert.IsType <JsonResult>(MvcAssert.JsonResult(jsonResult, new { Value = "TestValue" })); Assert.Equal(jsonResult, result); }