Hi All,
I have a simple testmethod
public double Divide(double numerator, double denominator)
{ if (denominator == 0) { throw new NullReferenceException("Cannot divide by zero."); } return numerator / denominator;
}
Now my Testcase data file looks like this
<TestCase>
<Numerator>-2.5</Numerator>
<Denominator>1</Denominator>
<ExpectedResult>-2.5</ExpectedResult>
</TestCase>
<TestCase>
<Numerator>55</Numerator>
<Denominator>5</Denominator>
<ExpectedResult>11</ExpectedResult>
</TestCase>
<TestCase>
<Numerator>5</Numerator>
<Denominator>0</Denominator>
<ExpectedResult>DivideByZeroException</ExpectedResult>
</TestCase>
What should be the way to include all these testcases into a single test method. My basic problem is to handle the exception test method. I know I can use [ExpectedException(typeof(DivideByZeroException)] attribute into test method, but in that case this method will not fit for other 2 test csaes.
Could someone please help me how I can accommodate all these test cases into a single method. Thanks in advance
Cheers, Pritam