public static int ConvertToInt(string str, int firstIndex, int lenOfString)
{
int Stop = firstIndex + lenOfString;
int Value = 0;
bool isNegative = false;
for (int i = firstIndex; i < Stop; i++)
{
if (i == 0 && str[i] == '-')
{
isNegative = true;
continue;
}
if (str[i] < '0' || str[i] > '9')
throw new FormatException("Sorry!! It is not in Numeric Format.");
Value = (Value * 10) + (str[i] - 48);
}
if (isNegative)
return (Value * -1);
return Value;
}
Above one is my part of code:
In above program I am converting string into Int. I go through from Here:
As I am new in Testing.I want to write all the possible positive and negative test cases for above program.for Testing purpose I am using NUnit framework.
How do I complete it?
Any help is appreciated.