I have a unit test project using Xunit and the method we are testing returns IActionResult
.
I saw some people suggest using "NegotiatedContentResult" to get the content of the IActionResult
but that doesn't work in Xunit.
So I wonder how to get the content value of an IActionResult
in Xunit?
Test code example is provided below:
public void GetTest()
{
var getTest = new ResourcesController(mockDb);
var result = getTest.Get("1");
//Here I want to convert the result to my model called Resource and
//compare the attribute Description like below.
Resource r = ?? //to get the content value of the IActionResult
Assert.Equal("test", r.Description);
}
Does anyone know how to do this in XUnit?