Skip to content

Instantly share code, notes, and snippets.

@cottsak
Created June 11, 2014 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cottsak/6b21b2e91efb01755dc5 to your computer and use it in GitHub Desktop.
Save cottsak/6b21b2e91efb01755dc5 to your computer and use it in GitHub Desktop.
public class controllers_should
{
[Fact]
public void derive_from_from_our_base()
{
foreach (var controller in GetControllersThatDontNeedAuth())
{
var authenticatedControllerType = typeof(AuthenticatedController);
Assert.True(controller.IsSubclassOf(authenticatedControllerType),string.Format("{0} should derive from {1}", controller.Name, authenticatedControllerType.Name));
//controller.IsSubclassOf(authenticatedControllerType).ShouldBe(true); // the message from this line isn't very helpful
}
}
}
@JakeGinnivan
Copy link

The error message for the commented out line should be:

controller.IsSubclassOf(authenticatedControllerType) Should Be true, which should be ok?

Or use controller.ShouldBeAssignableTo(authenticatedControllerType) instead

@cottsak
Copy link
Author

cottsak commented Jun 11, 2014

Error message is:

    controller.IsSubclassOf(authenticatedControllerType)
        should be
    True
        but was
    False

Not as helpful as: TestController should derive from AuthenticatedController

@robdmoore
Copy link

Inline authenticatedControllerType?

@cottsak
Copy link
Author

cottsak commented Jun 11, 2014

The message then becomes this Rob:

    controller.IsSubclassOf(typeof(AuthenticatedController))
        should be
    True
        but was
    False

not the greatest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment