Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        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");
        }
Beispiel #3
0
        public void ActAndAssertThrowsWhenActAndAssertDelegateIsNull()
        {
            var sut = new DataDrivenTest();

            sut.ActAndAssert(null);
        }
Beispiel #4
0
        public void ActAndAssertThrows()
        {
            var sut = new DataDrivenTest().Arrange("testcase");

            sut.ActAndAssert((string x) => { throw new InvalidOperationException(); });
        }