ChristianMurschall
ChristianMurschall

Reputation: 1711

Test out parameters with Nunit in a single statement

Is it possible to test the return value and out parametes with the same assert? Im looking for something like this:

Assert.That(int.TryParse("1", out var number), Is.True.And(// check for number == 1)); 

Upvotes: 2

Views: 280

Answers (1)

Prasad Telkikar
Prasad Telkikar

Reputation: 16079

You can try

Assert.IsTrue(int.TryParse("1", out var number) && number == 1);

POC: .net fiddle

** without Assert, just to check condition

Upvotes: 2

Related Questions