I would like to know how can I check if an object inherits from another class using Fluent Assertions?
I know I can do that with xUnit using IsAssignableFrom
, like so:
[Fact]
public void CreateBossEnemy()
{
//arrange
EnemyFactory sut = new EnemyFactory();
//action
var enemy = sut.Create("Zombie King", true);
//assert
Assert.IsAssignableFrom<Enemy>(enemy);
}
What would be the equivalent of IsAssignableFrom
for Fluent Assertions?
To check whether enemy
is assignable to the the type Enemy
you can use:
enemy.Should().BeAssignableTo<Enemy>();
Some resources:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With