FluentAssertions Should().BeOfType() or derived type?
Asked Answered
M

1

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?

Mantling answered 17/6, 2021 at 9:52 Comment(0)
F
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. :)

Footboard answered 17/6, 2021 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.