Writing simple test case
One of my friend asked me to write some example if we could say for test cases as he is going to interview for .NET Developer job and they propaly will ask him to do so which they did and a little snippet here let him pass the quistion so i decided to blog about it so may any one benfit
The thing is that for Developers job they usualy don't ask those big testing quistions or require you to write complix test cases but they certinly wanted to know that you have a bit background on the subject.
say you have a function that determine if the input is an even number
bool IsEven(int x)
if (x % 2 == 0)
In the line 3 i used % which will return the reminder of the division operation and checked if this match the 0 then the operation is for even number otherwise odd.
For testing such a function we will use the Assertion which provided through the namespace System.Diagnostics and the class Debug to write something like this.
Debug.Assert(IsEven(3) == true);
Debug.Assert(IsEven(0) == true);
Debug.Assert(IsEven(-5) == false);
Debug.Assert(IsEven(6) != IsEven(13));
If you intrested in the subject of Unit Testing i recommend you to take a read to Marc's Article . enjoy.