Created
February 23, 2012 23:25
-
-
Save bleis-tift/1895678 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"), | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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