8

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?

D.R.
  • 20,268
  • 21
  • 102
  • 205

1 Answers1

14

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. :)

Michaël Hompus
  • 3,349
  • 24
  • 35