-
Notifications
You must be signed in to change notification settings - Fork 731
Closed
Labels
Description
I use some reflection to test that all my controllers implement my BaseController.
When I test with AllBeAssignableTo it fails:
var myBaseControllerType = typeof(BaseController);
var controllers = myBaseControllerType.Assembly.Types().Where(x => x.Implements(typeof(ControllerBase)) && x != myBaseControllerType);
controllers.Should().AllBeAssignableTo<BaseController>();Expected type to be "MyProject.Controllers.BaseController", but found "[System.RuntimeType, System.RuntimeType, System.RuntimeType, System.RuntimeType]".
However, when I use foreach, it works like a charm
var myBaseControllerType = typeof(BaseController);
var controllers = myBaseControllerType.Assembly.Types().Where(x => x.Implements(typeof(ControllerBase)) && x != myBaseControllerType);
foreach (var controller in controllers)
{
controller.Should().BeAssignableTo<BaseController>();
}To me this is very unexpected. Can someone explain it? Or is it a bug? Not sure.
BR Matthias