Why does this simple assert statement fail? From what I've read I should be . Unfortunately, since the functionality is so basic there isn't much information out there.
public interface IDummy{}
public class Dummy : IDummy {}
Assert.IsAssignableFrom<IDummy>(new Dummy());
Running this test yields
Expected: assignable from <Application.Tests.ViewModels.IDummy>
But was: <Application.Tests.ViewModels.Dummy>
I have tried swapping the interface and objects side to no avail.
IsAssignableFrom works in reverse from what you are expecting. It's asking: Is (the value) Assignable From IDummy. Or: "Is assignable to (value)?"
From the XML doc: /// Asserts that an object may be assigned a value of a given Type.
You probably want Assert.IsInstanceOfType()
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