I have the method:
public static int Add(List numbers)
{
if (numbers == null || numbers.Count == 0)
return 0;
if
Just create the list inside the method instead, like this:
public void Add_WithOneNumber_ReturnsNumber()
{
var result = CalculatorLibrary.CalculatorFunctions.Add(new List<int>{1});
Assert.AreEqual(1, result);
}
You can't use objects only compile-time constants in data attributes. To avoid using reflection, which I find to be extremely unreadable and not at all appropriate for a test which is meant to formally describe behavior as clearly as possible, here's what I do:
[Test]
public void Test_Case_One()
{
AssertCurrency(INPUT, EXPECTED);
}
[Test]
public void Test_Case_Two()
{
AssertCurrency(INPUT, EXPECTED);
}
private void AssertScenario(int input, int expected)
{
Assert.AreEqual(expected, input);
}
It's a few more lines, but that's only because I want clear test output. You could just as easily put them in one [Test] if you are looking for something more concise.