Skip to content

Instantly share code, notes, and snippets.

@bleis-tift
Created February 23, 2012 23:25
Show Gist options
  • Save bleis-tift/1895678 to your computer and use it in GitHub Desktop.
Save bleis-tift/1895678 to your computer and use it in GitHub Desktop.
using NUnit.Framework;
[TestFixture]
public class Sample : TestUtil
{
[TestCaseSource("TestCases")]
public void Test(int i, string expected)
{
Assert.That(i.ToString(), Is.EqualTo(expected));
}
static object[] TestCases =
{
Given(1).Returns("1"),
Given(2).Returns("2"),
Given(3).Returns("3"),
};
}
using System;
using System.Linq;
public class TestUtil
{
public object[] Case(params object[] xs) { return xs; }
public Expect Given(params object[] args)
{
return new Expect(args);
}
public class Expect
{
readonly object[] args;
internal Expect(object[] args) { this.args = args; }
public object[] Returns(object expected)
{
return args.Concat(new[] { expected }).ToArray();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment