0

I've got a controller method that returns this to the client

return Ok(new { user, profile});

It used to return the user object on its own, so my unit test on the method looked like this

var res = await _controller.Get(_userId);
var okResult = res as OkObjectResult;
var resUser = okResult.Value as User;

i could then test individule bits of my return

Assert.Contains("user@domain.com", resUser.EmailAddress);

However, now i'm returning a a tuple object our of the controller method its not working. Ive tried doing

var resUser1 = okResult.Value as Tuple<User, Profile>;

But that always returns me null. Any idea how i can convert my result from the controller into something i can look into now its not just a flat object?

Thanks

beakersoft
  • 2,316
  • 6
  • 30
  • 40

1 Answers1

0

Ok, so i tried to use the ValueTuple to cast the result but it still seamed to bring back a null object, so i ended up just creating a real object for the result and casting to that object worked fine

beakersoft
  • 2,316
  • 6
  • 30
  • 40