ivaylokenov/MyTested.AspNetCore.Mvc

Response model of anonymous type cannot be tested

Zhelyazko777 opened this issue · 1 comments

If you have an action which returns a response model of type anonymous object and test if the response model is correct by passing a new anonymous object with the same fields in the test like:

public IActionResult SomeActionWhichReturnsViewWithAnnonimouseObject() 
{
    return View(new { someProperty = "" });
}
MyController<SomeController>
    .Instance()
    .Calling(c => c.SomeActionWhichReturnsWiewWithAnnonimouseObject())
    .ShouldReturn()
    .View(new { someProperty = "" }); 

I expect the test to pass, but instead it throws ResponseModelAssertionException.

Thank you for the bug report. I have added it to the current milestone, and it will be investigated.