Reputation: 10153
I need to have unconditional assert in C#.
This is for the case when my code execution gets to the point in the code where it shouldn`t arrive. I want to assert about that.
All methods od Assert
are conditional. Of course I can do Assert.IsFalse(true)
But I am not sure it is an elegant way
Any advises are welcome
Upvotes: 2
Views: 314
Reputation: 1282
You could use Assert.Fail() which can take a failure message
Assert.Fail();
Assert.Fail("Should not get here.");
Upvotes: 1