コード例 #1
0
        private static IEnumerable <TestUnit> TestUnits(params string[] names)
        {
            var testContext = SelfTestUtility.NewTestContext(null, new FakeRunner());

            foreach (var name in names)
            {
                var type = typeof(TestPlanFilterTests).GetNestedType(name, BindingFlags.NonPublic);
                yield return(new ReflectedTestClass(type));
            }
        }
コード例 #2
0
        public void Children_empty_implies_log_messages()
        {
            var tt      = new ReflectedTheory(GetType().GetMethod("PNoDataAttributesTheory"));
            var runner  = new FakeRunner();
            var context = SelfTestUtility.NewTestContext(tt, runner);

            tt.BeforeExecutingSafe(context);

            var evt = runner.Logger.Events;

            Assert.Equal("No test data for theory", ((TestMessageEventArgs)evt[0]).Message);
        }
コード例 #3
0
        public void CreateTest_will_be_skipped_with_error_when_multiple_test_attributes_specified()
        {
            var tc          = new ReflectedTestClass(typeof(PHasMethodWithMultipleAttributes));
            var testContext = SelfTestUtility.NewTestContext(tc, new FakeRunner());

            tc.InitializeSafe(testContext);

            var exec   = new FakeTestExecutionContext(testContext, (TestCaseInfo)tc.Children[0], new PHasMethodWithMultipleAttributes());
            var result = exec.RunCurrentTest();

            Assert.Equal("Problem creating test (SpecException: Method has more than one fact or theory attribute)", result.Reason);
            Assert.True(result.Failed);
        }
コード例 #4
0
        public void Children_empty_implies_theory_is_failed()
        {
            Assert.UseStrictMode = true;
            try {
                var tt      = new ReflectedTheory(GetType().GetMethod("PNoDataAttributesTheory"));
                var runner  = new FakeRunner();
                var context = SelfTestUtility.NewTestContext(tt, runner);
                tt.BeforeExecutingSafe(context);

                Assert.True(tt.Failed);
                Assert.Equal("No test data for theory", tt.Reason);
            } finally {
                Assert.UseStrictMode = false;
            }
        }
コード例 #5
0
        public void TestUnitFromType_should_find_private_methods(Type type)
        {
            var asm         = TestAssembly.Create(GetType().Assembly);
            var test        = asm.TestUnitFromType(type);
            var testContext = SelfTestUtility.NewTestContext(null, new FakeRunner());

            test.InitializeSafe(testContext);
            Assert.HasCount(
                1,
                test.Children
                );
            Assert.EndsWith(
                "PFact",
                test.Children[0].DisplayName
                );
        }