today I want to share with you small explanation about how xUnit works.
Take a look at presented code:
[InlineData(3, 4, 5)]
[InlineData(7, 8, 9)]
public void MethodDemo(int numberOne, int numberTwo, int numberThree)
double data = new double;
data = new double;
data = numberOne;
data = numberTwo;
data = numberThree;
var sut = new Matrix(data);
If to describe this code in words, it has following meaning.
- Attribute Theory says that it is test method which should be exeuted.
- Repeated twice Attribute InlineData says that method MethodDemo should be executed twice, with assigning to numberOne value 3 during first execution, value 7 during second execution. Number 4 to variable numberTwo in first execution, 8 to numberTwo variable during second execution and so on.
Take a look at picture that has visual representation:
I know that it is maybe not the best picture that you've seen in your life, but I hope it's self explanatory.