I have a window form with one button and I am trying to test it with codedUitest. I want the test to fail if any exception is thrown but in the test class it doesn't catch the exception.
Here is my code:
public void button1_Click(object sender, EventArgs e)
{
double[] dummy = new double[1];
int i = 1;
if (i > 0)
{
throw new System.IndexOutOfRangeException("index parameter is out of range.");
}
else
{
dummy[i] = 6;
}
}
The test method is:
public void CodedUITestMethod1()
{
try
{
this.UIMap.TryBtn1();
}
catch (IndexOutOfRangeException)
{
Assert.Fail();
}
}