One thing that we have run into is the need to have a test that determines if an particular exception is being thrown are part of the test. In our case, it is to verify that the proper validation logic is being called.
In order to support this, I have written a function for the FlowFixtureBase called "Exception".
public void Exception(Parse theCells) {
string msg = theCells.Last.Text ;
try {
ExecuteEmbeddedMethod(theCells, 1);
AddCell(theCells, "No exception thrown");
Wrong(theCells);
}
catch (IgnoredException) {}
catch (Exception e) {
if ( e.InnerException.Message.IndexOf(msg) > 0 )
Right(theCells);
else
{
AddCell(theCells, e.Message);
Wrong(theCells);
}
}
}
It can then be used easily within a test like this:
|Exception|MyMethodCall|The expected exception message text goes here|
This little method has been very useful to us, and we wanted to contribute it back to the Fitlibrary.NET project.
Regards,
Ron Evans
ron.evans@gmail.com
http://www.deadprogrammersociety.com
Logged In: YES
user_id=1229712
Originator: YES
I just noticed a small error in the code that I uploaded. here is a revised version...
public void Exception(Parse theCells) {
string msg = theCells.Last.Text ;
try {
ExecuteEmbeddedMethod(theCells, 1);
AddCell(theCells, "No exception thrown");
Wrong(theCells);
}
catch (IgnoredException) {}
catch (Exception e) {
if ( e.InnerException.Message.IndexOf(msg) > 0 )
Right(theCells);
else
{
AddCell(theCells, e.InnerException.Message);
Wrong(theCells);
}
}
}
File Added: FlowFixtureBase.cs