Skip to content

Instantly share code, notes, and snippets.

@alexwirz
Created August 2, 2015 14:29
Show Gist options
  • Save alexwirz/926f054f6705914c8778 to your computer and use it in GitHub Desktop.
Save alexwirz/926f054f6705914c8778 to your computer and use it in GitHub Desktop.
Create test combinations for legacy code.
[UseReporter(typeof(DiffReporter))]
[TestClass]
public class TestCombinations
{
public string RunLegacyManagerProcessor(string a, int b, bool c)
{
if (c) return "42";
if (b > 12) return a.Length.ToString();
return b.ToString();
}
[TestMethod]
public void TestAllCombinations()
{
var name = new[] { "Jack" };
var age = new[] { 42 };
var isRegistered = new[] { false };
CombinationApprovals.VerifyAllCombinations(RunLegacyManagerProcessor, name, age, isRegistered);
}
[TestMethod]
public void TestMoreCombinations()
{
var name = new[] { "Jack", "John", "Steve" };
var age = new[] { 42, 23, 15 };
var isRegistered = new[] { false, true };
CombinationApprovals.VerifyAllCombinations(RunLegacyManagerProcessor, name, age, isRegistered);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment