Ejemplo n.º 1
0
        public void Run_OneFailingAsyncTest_ShouldThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", async() => await Task.Delay(1).ConfigureAwait(false));
            tests.AddTest("Test2", async() =>
            {
                await Task.Delay(1).ConfigureAwait(false);
                throw new AssertionException("xyzzy");
            });

            try
            {
                tests.RunTests("MyTests");
            }
            catch (AssertionException e)
            {
                e.ExpectMessage("MyTests");
                e.ExpectInnerAssertion("Test2 failed.");
                e.ExpectInnerAssertion("xyzzy");
                return;
            }

            Fail("RunTests did not throw.");
        }
Ejemplo n.º 2
0
        public void Run_PassingTests_ShouldNotThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", () => { });
            tests.AddTest("Test2", () => { });

            tests.RunTests("MyTests");
        }
Ejemplo n.º 3
0
        public void Run_PassingAsyncTests_ShouldNotThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", async() => await Task.Delay(1).ConfigureAwait(false));
            tests.AddTest("Test2", async() => await Task.Delay(1).ConfigureAwait(false));

            tests.RunTests("MyTests");
        }
Ejemplo n.º 4
0
        public void Run_OneFailingTest_ShouldThrow()
        {
            var tests = new TestCollection();

            tests.AddTest("Test1", () => { });
            tests.AddTest("Test2", () => throw new AssertionException("xyzzy"));

            try
            {
                tests.RunTests("MyTests");
            }
            catch (AssertionException e)
            {
                e.ExpectMessage("MyTests");
                e.ExpectInnerAssertion("Test2 failed.");
                e.ExpectInnerAssertion("xyzzy");
                return;
            }

            Fail("RunTests did not throw.");
        }