YAKOVM
YAKOVM

Reputation: 10153

how can I make unconditional assert

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

Answers (2)

Kurtis
Kurtis

Reputation: 1282

You could use Assert.Fail() which can take a failure message

Assert.Fail();
Assert.Fail("Should not get here."); 

Upvotes: 1

Dom84
Dom84

Reputation: 864

Therefor you can use

Assert.Fail("Some message");

Upvotes: 3

Related Questions