vendredi 20 mars 2015

How to structure my unit test?

I am new to unit test and wondering how to start testing. The application I am currently working on, does not have any unit test. It a winform application and I am only interested to test the data layer of this application.


Here is an example.



public interface ICalculateSomething
{
SomeOutout1 CalculateSomething1(SomeInput1 input1);
SomeOutout2 CalculateOSomething2(SomeInput2 input2);
}

public class CalculateSomething : ICalculateSomething
{

SomeOutout1 ICalculateSomething.CalculateSomething1(SomeInput1 input1)
{
SomeOutout1.Prop1 = calculateFromInput1(input1.Prop1, input1.Prop2);

SomeOutout1.Prop3 = calculateFromInput2(input1.Prop3, input1.Prop4);

return SomeOutout1;
}

SomeOutout2 ICalculateSomething.CalculateOSomething2(SomeInput2 input2)
{
SomeOutout2.Prop1 = calculateFromInput1(input2.Prop1, input2.Prop2);

SomeOutout2.Prop3 = calculateFromInput2(input2.Prop3, input2.Prop4);

return SomeOutout2;
}
}


I would like to test these two methods in the CalculateSomething. Those methods implementation are long and complicated. How should I structure my test?


Aucun commentaire:

Enregistrer un commentaire