I want to create tests that tests all combinations of parameters excluding one combination that will have a different expected result.
So far I have come up with
[TestCase(false, false, ExpectedResult = false)]
[TestCase(false, true, ExpectedResult = false)]
[TestCase(true, false, ExpectedResult = false)]
[TestCase(true, true, ExpectedResult = true)]
public bool Test(bool paramA bool paramB)
{
var target = new MyComand(paramA, paramB);
return target.CanExecute();
}
// this class is made up, but shows the basic concept
public class MyCommand
{
bool _preConditionA;
bool _preConditionB;
public MyCommand(bool preConditionA, bool preConditionB)
{
_preConditionA = preConditionA;
_preConditionB = preConditionB;
}
public bool CanExecute()
{
if (_preConditionA == false)
return false;
if (_preConditionB == false)
return false;
return true;
}
}
Or with some crazy [TestCaseSource].
Both cases have a problem with the readability for me personally.
This gets more complicated when the parameters are not only boolean.
I checked into the [Values] and [Combinatorical] attributes, but they don't really work for my case.
Does anybody know any other way to solve this?