There are several philosophies. Roy Osherove, author of The Art of Unit Testing, seems to prefer using explicit values, and selecting the lowest (or simplest) representation of each Equivalence Class.
That principle doesn't apply itself particularly well to your example, but works really well in many other scenarios.
If, for example, a class requires an input of a positive integer, you pick the number 1 because it's the simplest representation of all positive intergers.
Personally, I rather prefer a principle I call Constrained Non-Determinism. The point here is that we let some kind of factory serve us anonymous variables for the given type, because it forces us to establish the relationship directly in the test.
I'm using AutoFixture to do this (but you could also use something else), so in this case I would test the SumCalculator like this:
var fixture = new Fixture();
var int1 = fixture.CreateAnonymous<int>();
var int2 = fixture.CreateAnonymous<int>();
var expectedResult = int1 + int2;
var sut = fixture.CreateAnonymous<SumCalculator>();
var result = sut.Calculate(int1, int2);
Assert.AreEqual(expectedResult, result);
In principle, this single test provides a specification for the Calculate method. We never know what the values of int1
and int2
are, and that is very appropriate in all those many cases where it actually doesn't matter.