Q:

How do you access the data returned by a controller when run in unit tests?

I have a Asp .net core 2.2 web api.  I am trying to set up unit testing on a number of the controllers.   I have it working to he point where it does call the controller
Controller
[HttpGet("list")]
public ActionResult Get([FromQuery] string q = null)
    {
        if (q != null)
            return Ok(new ClientListResponse(ClientHelper.FindClientByClientIdOrClientName(_configurationDbContext.Clients, q)));

        return Ok(new ClientListResponse(_configurationDbContext.Clients.ToList()));
    }

Test calling it
var allClients = controller.Get();  

Issue
Now when i look at it in debug everything looks fine. I can see that value contains the correct object being returned.

However when it try to access the variables they don't exist.

I am suspecting that this has something to do with the response being an ActionResult.  I have tried to convert it to everything i can think of.
How do you access the data returned by a controler when run in unit tests?

A:

Cast it to an OkObjectResult.
In ours:
var controller = SetupAdminTestsForPassword();
var result = controller.ValidateTokenForUserCreation(new ValidateUserTokenRequest() { token = "VALIDCREATEUSERTOKEN"});
var okResult = result as OkObjectResult;

// assert
Assert.IsNotNull(okResult);
Assert.IsNotNull(okResult.Value);
Assert.IsNotNull(okResult.Value as ValidateUserTokenResponse);
Assert.IsTrue((okResult.Value as ValidateUserTokenResponse).IsValid);

We're also using dotnet core 2.2 and Moq for tests.

