Do you think that this is a good way for testing exceptions? Any suggestions?
Exception exception = null;
try{
//I m sure that an exeption will happen he
Suggest using NUnit's clean delegate syntax.
Example for testing ArgumentNullExeption
:
[Test]
[TestCase(null)]
public void FooCalculation_InvalidInput_ShouldThrowArgumentNullExeption(string text)
{
var foo = new Foo();
Assert.That(() => foo.Calculate(text), Throws.ArgumentNullExeption);
//Or:
Assert.That(() => foo.Calculate(text), Throws.Exception.TypeOf);
}