Exemplo n.º 1
0
        public Test BuildFrom(Type type)
        {
            NativeTestFactory nativeTestFactory = new NativeTestFactory();

            SpecificationBuilder.BuildTestFixture(type, nativeTestFactory, new GlobalSetupOwner());

            var result = nativeTestFactory.RootTest.GetNative() as Test;

            NUnitFramework.ApplyCommonAttributes(type.GetCustomAttributes(false).Cast <Attribute>().ToArray(), result);

            return(result);
        }
Exemplo n.º 2
0
        protected static GenericTestFactory RunTestDiscovery(Assembly assembly, Func <Type, bool> typeFilter)
        {
            GenericTestFactory nativeTestFactory = new GenericTestFactory();

            var filteredTypes = assembly.GetTypes().Where(t => FixtureClassifier.IsTypeSpecification(t)).Where(typeFilter);

            foreach (var type in filteredTypes)
            {
                SpecificationBuilder.BuildTestFixture(type, nativeTestFactory, nativeTestFactory.GlobalSetupOwner);
            }

            return(nativeTestFactory);
        }
        public void can_load_tests()
        {
            Type type = typeof(has_test_in_loop);

            var nativeTestFactory = new TrackingTestFactory();

            using (var globalSetupOwner = new GlobalSetupOwner())
            {
                SpecificationBuilder.BuildTestFixture(type, nativeTestFactory, globalSetupOwner);

                expect(() => nativeTestFactory.Results[TestPosition.At(0)] == "a1");
                expect(() => nativeTestFactory.Results[TestPosition.At(1)] == "a2");
                expect(() => nativeTestFactory.Results[TestPosition.At(2)] == "a3");
                expect(() => nativeTestFactory.Results[TestPosition.At(3)] == "nested");
                expect(() => nativeTestFactory.Results[TestPosition.At(3, 0)] == "b1");
                expect(() => nativeTestFactory.Results[TestPosition.At(3, 1)] == "b2");
                expect(() => nativeTestFactory.Results[TestPosition.At(3, 2)] == "b3");
            }
        }