Skip to content

Test framework

irxground edited this page Sep 8, 2012 · 2 revisions

.NET のLambda式を使って以下のようにテストが書けるようにしたい。

class Program {

public void Main() { Spec.RunAllTest(); }

[TestCase]
public void MethodA() {
    Spec.Describe("Integer is addable.")
        .Assert(1 + 1, v => v == 2);

    Spec.Assert(3 - 2, v => v == 1)
        .Describe("Integer is subtractable.");

    Spec.Target(10)
        .Should(x => x > 9)
        .Should(x => x % 2 == 0)

    Spec.Target(() => { throw new NotImplementedException() })
        .ShouldThorow<NotImplementedException>()
}
}

Clone this wiki locally