Unit tests for my controller include type validation of the model.
I first attempted:
ViewResult.Model.Should().BeOfType<IEnumerable<model>>()
but it failed, stating that the type is List<model>
This is true, but I don't want to worry about that during my testing... I just need to verify that the model is IEnumerable
As a result, I must use:
ViewResult.Model.GetType().Implements<IEnumerable<model>>().Should().BeTrue()
I would prefer something along the lines of:
- some sort of optional parameter for the BeOfType() to allow classes that inherit/implement T
or
- BeOfTypeImplementing<>
PS: keep up the great work... FA is probably my most frequently used nuget package :)
Comments: Is that an answer to your question?
I first attempted:
ViewResult.Model.Should().BeOfType<IEnumerable<model>>()
but it failed, stating that the type is List<model>
This is true, but I don't want to worry about that during my testing... I just need to verify that the model is IEnumerable
As a result, I must use:
ViewResult.Model.GetType().Implements<IEnumerable<model>>().Should().BeTrue()
I would prefer something along the lines of:
- some sort of optional parameter for the BeOfType() to allow classes that inherit/implement T
or
- BeOfTypeImplementing<>
PS: keep up the great work... FA is probably my most frequently used nuget package :)
Comments: Is that an answer to your question?