public void ActAndAssertThrowsWhenNoTestCasesHaveBeenArranged() { var expected = "Assert.Fail failed. There are no test cases. Have you forgotten to arrange them?"; try { var sut = new DataDrivenTest(); sut.ActAndAssert((object x) => { }); } catch (AssertFailedException ex) { Assert.AreEqual(expected, ex.Message); } }
public void ActAndAssertIsCalledCorrectly() { var sut = new DataDrivenTest() .Arrange("test 0", "case 0") .Arrange("test 1", "case 1"); var actualCallCount = 0; var act = new Action <string, string>((test, expected) => { Assert.AreEqual(test, $"test {actualCallCount}"); Assert.AreEqual(expected, $"case {actualCallCount}"); actualCallCount++; }); sut.ActAndAssert(act); Assert.AreEqual(2, actualCallCount, "Act should be called twice"); }
public void ActAndAssertThrowsWhenActAndAssertDelegateIsNull() { var sut = new DataDrivenTest(); sut.ActAndAssert(null); }
public void ActAndAssertThrows() { var sut = new DataDrivenTest().Arrange("testcase"); sut.ActAndAssert((string x) => { throw new InvalidOperationException(); }); }