9

I have the following situation:

class A
{
}

class B : A
{
}

I want to assert that variables of typeof(B) are assignable to typeof(A) variables. How to do that with fluent assertions?

1 Answer 1

15

I think you can use BeAssignableTo<T> for this:

var b = new B();
        
b.Should().BeAssignableTo<A>();

This is almost your own sentence you have written. :)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.