Beispiel #1
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("EC Math tests");

            suite.Add(new ECAlgorithmsTest());
            suite.Add(new ECPointTest());

            return suite;
        }
Beispiel #2
0
		public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("TSP Tests");

			suite.Add(new GenTimeAccuracyUnitTest());
			suite.Add(new ParseTest());
			suite.Add(new TimeStampTokenInfoUnitTest());
			suite.Add(new TspTest());

			return suite;
        }
Beispiel #3
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("ASN.1 tests");

            suite.Add(new AllTests());

            // TODO Add these tests to RegressionTest list
            suite.Add(new Asn1SequenceParserTest());
            suite.Add(new OctetStringTest());
            suite.Add(new ParseTest());
            suite.Add(new TimeTest());

            return suite;
        }
Beispiel #4
0
		void Build (TestSuite suite)
		{
//			if (Environment.GetEnvironmentVariables().Contains("START_DEBUG"))
//				System.Diagnostics.Debugger.Launch ();
			ReadLists ();
			XmlDocument whole = new XmlDocument ();
			whole.Load (@"testsuite/TESTS/catalog-fixed.xml");

			foreach (XmlElement testCase in whole.SelectNodes ("test-suite/test-catalog/test-case")) {
				string testid = testCase.GetAttribute ("id");

				if (skipTargets.Contains (testid))
					continue;

				CatalogTestCase ctc = new CatalogTestCase(EnvOptions.OutputDir, testCase);
				if (!ctc.Process ())
					continue;

				SingleTestTransform stt = new SingleTestTransform (ctc);

				string expectedException = (string) expectedExceptions[testid];
				bool isKnownFailure = knownFailures.Contains (testid) || fixmeList.Contains (testid);

				suite.Add (new TestFromCatalog (testid, stt, expectedException,
					EnvOptions.InverseResults, isKnownFailure));
			}
		}
 public Test BuildFrom(Type type)
 {
     var testSuite = new TestSuite(type.FullName);
     testSuite.Add(new ConcordionTest(type));
     NUnitFramework.ApplyCommonAttributes(type, testSuite);
     return testSuite;
 }
Beispiel #6
0
		public static TestSuite suite()
		{
			TestSuite suite = new TestSuite("IO tests");

			suite.Add(new CipherStreamTest());

			return suite;
		}
Beispiel #7
0
		public static TestSuite suite()
		{
			TestSuite suite = new TestSuite("OCSP Tests");

			suite.Add(new OcspTest());

			return suite;
		}
		public void SetUp()
		{
			testSuite = new TestSuite("MyTestSuite");
			testFixture = TestFixtureBuilder.BuildFrom( typeof( MockTestFixture ) );
			testSuite.Add( testFixture );

			testCase = TestFinder.Find("MockTest1", testFixture, false);
		}
Beispiel #9
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("Math tests");

            suite.Add(new BigIntegerTest());

            return suite;
        }
        public TestT BuildFrom(MethodInfo method, TestT parentSuite)
        {
            TestSuite testT = new TestSuite(method.Name);
            NUnitFramework.ApplyCommonAttributes(method, testT);

            ArrayList hierachyNodeList = new ArrayList();
            foreach (ProviderReference reference in GetBuildersFor(method, parentSuite))
            {
                System.Collections.Specialized.ListDictionary contextProperties
                     = new System.Collections.Specialized.ListDictionary();
                //테스트 함수에 지정된 특성값을 계층노드의 속성으로 복사합니다.
                foreach (DictionaryEntry entry in testT.Properties)
                {
                    if ((string)entry.Key != DESCRIPTION
                        && (string)entry.Key != CATEGORIES)
                    {
                        contextProperties[entry.Key] = entry.Value;
                    }
                }

                HierachyNode baseNode = new HierachyNode(method.Name);
                baseNode = reference.GetInstance(baseNode, contextProperties) as HierachyNode;
                if (baseNode != null)
                {
                    hierachyNodeList.Add(baseNode);
                }
            }

            ArrayList testSuiteList = new ArrayList();
            foreach (HierachyNode hierachyNode in hierachyNodeList)
            {
                TestSuite testSuite = new TestSuite(hierachyNode.Name);
                this.BuildTestSuiteTree(method, ref testSuite, hierachyNode);
                testSuiteList.Add(testSuite);
            }

            if (testSuiteList.Count > 0)
            {
                if (testSuiteList.Count == 1)
                {
                    testT = testSuiteList[0] as TestSuite;
                }
                else
                {
                    testT = new TestSuite(method.Name);
                    NUnitFramework.ApplyCommonAttributes(method, testT);
                    foreach (TestSuite testSuite in testSuiteList)
                    {
                        testT.Add(testSuite);
                    }
                }
            }

            return testT;
        }
 private static void CreateTests(TestSuite fixture, XmlElement fixtureElement)
 {
     foreach (XmlElement testElement in fixtureElement.SelectNodes("Test"))
     {
         string name = testElement.GetAttribute("Name");
         if (name.Length > 0)
         {
             GrammarTest test = new GrammarTest(fixture.Name, name, testElement);
             fixture.Add(test);
         }
     }
 }
		public void SetUp()
		{
			testSuite = new TestSuite("MyTestSuite");
			testFixture = TestFixtureBuilder.BuildFrom( typeof( MockTestFixture ) );
			testSuite.Add( testFixture );

			suiteInfo = new TestInfo( testSuite );
			fixtureInfo = new TestInfo( testFixture );

			testCase = (NUnit.Core.Test)testFixture.Tests[0];
			testCaseInfo = new TestInfo( testCase );
		}
 private static void CreateTestFixtures(TestSuite suite, XmlDocument suiteDoc)
 {
     foreach (XmlElement fixtureElement in suiteDoc.DocumentElement.SelectNodes("TestFixture"))
     {
         string name = fixtureElement.GetAttribute("Name");
         if (name.Length > 0)
         {
             TestSuite fixture = new TestSuite(name);
             suite.Add(fixture);
             CreateTests(fixture, fixtureElement);
         }
     }
 }
Beispiel #14
0
        /// <summary>
        /// Go through the Test tree, building a tree of TestFixures with Test nodes. 
        /// </summary>
        private void MapTestTreeToFixtures(TreeDictionary<string, TestClosure> source, TestSuite container, Type fixtureType)
        {
            foreach (var testClosure in source.Items) {
                container.Add(new ClosureTest(testClosure));
            }

            foreach (var child in source.Children) {
                var fixture = new TestFixture(fixtureType);
                fixture.TestName.Name = child.Key;
                foreach (var testClosure in child.Value.Items) {
                    fixture.Add(new ClosureTest(testClosure));
                }

                foreach (var sub_child in child.Value.Children) {
                    var sub_fixture = new TestFixture(fixtureType);
                    sub_fixture.TestName.Name = sub_child.Key;
                    MapTestTreeToFixtures(sub_child.Value, sub_fixture, fixtureType);
                    fixture.Add(sub_fixture);
                }
                container.Add(fixture);
            }
        }
Beispiel #15
0
		public void Run()
		{
			TestClass fixture = new TestClass();
			
			TestSuite parentSuite = new TestSuite("ParentSuiteName", "Name");
			parentSuite.Fixture = fixture;
			
			RowTestSuite rowTestSuite = new RowTestSuite(GetRowTestMethodWith2Rows());
			parentSuite.Add(rowTestSuite);
			
			rowTestSuite.Run(new NullListener(),TestFilter.Empty);
			
			Assert.That(rowTestSuite.Fixture, Is.SameAs(fixture));
		}
Beispiel #16
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("CMS Tests");

            suite.Add(new CompressedDataTest());
            suite.Add(new CompressedDataStreamTest());
            suite.Add(new EnvelopedDataTest());
            suite.Add(new EnvelopedDataStreamTest());
            suite.Add(new Rfc4134Test());
            suite.Add(new SignedDataTest());
            suite.Add(new SignedDataStreamTest());

            return suite;
        }
        public void SetUp()
        {
            MethodInfo fakeTestMethod = GetType().GetMethod("FakeTestCase", BindingFlags.Instance | BindingFlags.NonPublic);
            var nunitTest = new NUnitTestMethod(fakeTestMethod);
            nunitTest.Categories.Add("cat1");
            nunitTest.Properties.Add("Priority", "medium");

            var nunitFixture = new TestSuite("FakeNUnitFixture");
            nunitFixture.Categories.Add("super");
            nunitFixture.Add(nunitTest);

            Assert.That(nunitTest.Parent, Is.SameAs(nunitFixture));

            var fixtureNode = new TestNode(nunitFixture);
            fakeNUnitTest = (ITest)fixtureNode.Tests[0];

            testConverter = new TestConverter(new TestLogger(), ThisAssemblyPath);
        }
Beispiel #18
0
        /// <summary>
        /// Build a suite based on a TestPackage
        /// </summary>
        /// <param name="package">The TestPackage</param>
        /// <returns>A TestSuite</returns>
        public TestSuite Build( TestPackage package )
        {
            bool autoNamespaceSuites = package.GetSetting( "AutoNamespaceSuites", true );
            bool mergeAssemblies = package.GetSetting( "MergeAssemblies", false );

            if ( package.IsSingleAssembly )
                return BuildSingleAssembly( package );

            TestSuite rootSuite = new TestSuite( package.FullName );
            NamespaceTreeBuilder namespaceTree =
                new NamespaceTreeBuilder( rootSuite );

            builders.Clear();
            foreach(string assemblyName in package.Assemblies)
            {
                TestAssemblyBuilder builder = new TestAssemblyBuilder();
                builders.Add( builder );

                Test testAssembly =  builder.Build( assemblyName, package.TestName, autoNamespaceSuites && !mergeAssemblies );

                if ( testAssembly != null )
                {
                    if (!mergeAssemblies)
                    {
                        rootSuite.Add(testAssembly);
                    }
                    else if (autoNamespaceSuites)
                    {
                        namespaceTree.Add(testAssembly.Tests);
                        rootSuite = namespaceTree.RootSuite;
                    }
                    else
                    {
                        foreach (Test test in testAssembly.Tests)
                            rootSuite.Add(test);
                    }
                }
            }

            if ( rootSuite.Tests.Count == 0 )
                return null;

            return rootSuite;
        }
Beispiel #19
0
        public void Add(TestSuite fixture)
        {
            string ns    = fixture.TestName.FullName;
            int    index = ns.LastIndexOf('.');

            ns = index > 0 ? ns.Substring(0, index) : string.Empty;
            TestSuite containingSuite = BuildFromNameSpace(ns);

            if (fixture is SetUpFixture)
            {
                // The SetUpFixture must replace the namespace suite
                // in which it is "contained".
                //
                // First, add the old suite's children
                foreach (TestSuite child in containingSuite.Tests)
                {
                    fixture.Add(child);
                }

                // Make the parent of the containing suite point to this
                // fixture instead
                // TODO: Get rid of this somehow?
                TestSuite parent = (TestSuite)containingSuite.Parent;
                if (parent == null)
                {
                    fixture.TestName.Name = rootSuite.TestName.Name;
                    rootSuite             = fixture;
                }
                else
                {
                    parent.Tests.Remove(containingSuite);
                    parent.Add(fixture);
                }

                // Update the hashtable
                namespaceSuites[ns] = fixture;
            }
            else
            {
                containingSuite.Add(fixture);
            }
        }
		public void Add( TestSuite fixture )
		{
            if (fixture != null)
            {
                string ns = fixture.TestName.FullName;
                int index = ns.IndexOf("[");
                if (index >= 0) ns = ns.Substring(0, index);
                index = ns.LastIndexOf('.');
                ns = index > 0 ? ns.Substring(0, index) : string.Empty;
                TestSuite containingSuite = BuildFromNameSpace(ns);

                if (fixture is SetUpFixture)
                {
                    // The SetUpFixture must replace the namespace suite
                    // in which it is "contained". 
                    //
                    // First, add the old suite's children
                    foreach (TestSuite child in containingSuite.Tests)
                        fixture.Add(child);

                    // Make the parent of the containing suite point to this
                    // fixture instead
                    // TODO: Get rid of this somehow?
                    TestSuite parent = (TestSuite)containingSuite.Parent;
                    if (parent == null)
                    {
                        fixture.TestName.Name = rootSuite.TestName.Name;
                        rootSuite = fixture;
                    }
                    else
                    {
                        parent.Tests.Remove(containingSuite);
                        parent.Add(fixture);
                    }

                    // Update the hashtable
                    namespaceSuites[ns] = fixture;
                }
                else
                    containingSuite.Add(fixture);
            }
		}
        //public void Add( SetUpFixture fixture )
        //{
        //    string ns = fixture.FullName;
        //    int index = ns.LastIndexOf( '.' );
        //    ns = index > 0 ? ns.Substring( 0, index ) : string.Empty;
        //    TestSuite suite = BuildFromNameSpace( ns );

        //    // Make the parent point to this instead
        //    // TODO: Get rid of this somehow?
        //    TestSuite parent = suite.Parent;
        //    if ( parent != null )
        //    {
        //        parent.Tests.Remove( suite );
        //        parent.Add( fixture );
        //    }

        //    // Add the old suite's children
        //    foreach( TestSuite child in suite.Tests )
        //        fixture.Add( child );

        //    if (parent == null && fixture is SetUpFixture)
        //    {
        //        suite.Tests.Clear();
        //        suite.Add(fixture);
        //    }
        //    // Update the hashtable
        //    namespaceSuites[ns] = fixture;
        //}

        #endregion

        #region Helper Method

        private TestSuite BuildFromNameSpace(string nameSpace)
        {
            if (nameSpace == null || nameSpace == "")
            {
                return(rootSuite);
            }
            TestSuite suite = (TestSuite)namespaceSuites[nameSpace];

            if (suite != null)
            {
                return(suite);
            }

            int index = nameSpace.LastIndexOf(".");

            //string prefix = string.Format( "[{0}]" );
            if (index == -1)
            {
                suite = new TestSuite(nameSpace);
                if (rootSuite == null)
                {
                    rootSuite = suite;
                }
                else
                {
                    rootSuite.Add(suite);
                }
                namespaceSuites[nameSpace] = suite;
            }
            else
            {
                string    parentNameSpace = nameSpace.Substring(0, index);
                TestSuite parent          = BuildFromNameSpace(parentNameSpace);
                string    suiteName       = nameSpace.Substring(index + 1);
                suite = new TestSuite(parentNameSpace, suiteName);
                parent.Add(suite);
                namespaceSuites[nameSpace] = suite;
            }

            return(suite);
        }
Beispiel #22
0
        public Test BuildFrom(Type type)
        {
            var instance = Reflect.Construct(type);
            var result = new TestSuite(type) {Fixture = instance};

            foreach (var property in GetTestSourcePropertiesFrom(type))
            {
                var testSource = (ITestSource) property.GetValue(instance, null);
                if (!testSource.TestContext.HasTests)
                    continue;

                var suite = new TestSuite(string.Format("{0} {1}", testSource.TestContext.ArrangeDescription,
                                                        testSource.TestContext.ActDescription));
                foreach (var testInformation in testSource.TestContext.Tests)
                {
                    suite.Add(new LingualTest(testInformation));
                }
                result.Add(suite);
            }
            return result;
        }
Beispiel #23
0
        public TestSuite Build(string assemblyName, string testName)
        {
            TestSuite suite = null;

            Assembly assembly = Load(assemblyName);

            if (assembly != null)
            {
                Type testType = assembly.GetType(testName);
                if (testType != null)
                {
                    return(MakeSuite(testType));
                }

                // Assume that testName is a namespace
                string prefix = testName + '.';

                Type[] testTypes        = assembly.GetExportedTypes();
                int    testFixtureCount = 0;

                foreach (Type type in testTypes)
                {
                    if (CanMakeSuite(type) && type.Namespace != null)
                    {
                        if (type.Namespace == testName || type.Namespace.StartsWith(prefix))
                        {
                            suite = BuildFromNameSpace(testName, 0);

                            //suite.Add( new TestFixture( type ) );
                            suite.Add(MakeSuite(type));
                            testFixtureCount++;
                        }
                    }
                }

                return(testFixtureCount == 0 ? null : rootSuite);
            }

            return(suite);
        }
 private void AddDataSet(ref TestSuite suite, MethodInfo method, List<object> arguments, int counter, List<object> dataset)
 {
     if (counter >= dataset.Count)
         suite.Add(new IterativeTestCase(method, arguments.ToArray()));
     else
     {
         if (dataset[counter].GetType().GetInterface("IEnumerable") != null)
         {
             foreach (object arg in (IEnumerable)dataset[counter])
             {
                 List<object> new_args = new List<object>(arguments);
                 new_args.Add(arg);
                 AddDataSet(ref suite, method, new_args, counter + 1, dataset);
             }
         }
         else
         {
             List<object> new_args = new List<object>(arguments);
             new_args.Add(dataset[counter]);
             AddDataSet(ref suite, method, new_args, counter + 1, dataset);
         }
     }
 }
Beispiel #25
0
        private TestSuite BuildTestAssembly(string assemblyName, IList fixtures, bool autoSuites)
        {
            TestSuite testAssembly = new TestSuite(assemblyName);

            if (autoSuites)
            {
                NamespaceTreeBuilder treeBuilder =
                    new NamespaceTreeBuilder(testAssembly);
                treeBuilder.Add(fixtures);
                testAssembly = treeBuilder.RootSuite;
            }
            else
                foreach (TestSuite fixture in fixtures)
                {
                    if (fixture is SetUpFixture)
                    {
                        fixture.RunState = RunState.NotRunnable;
                        fixture.IgnoreReason = "SetUpFixture cannot be used when loading tests as a flat list of fixtures";
                    }

                    testAssembly.Add(fixture);
                }

            if (fixtures.Count == 0)
            {
                testAssembly.RunState = RunState.NotRunnable;
                testAssembly.IgnoreReason = "Has no TestFixtures";
            }

            NUnitFramework.ApplyCommonAttributes(assembly, testAssembly);

            testAssembly.Properties["_PID"] = System.Diagnostics.Process.GetCurrentProcess().Id;
            testAssembly.Properties["_APPDOMAIN"] = AppDomain.CurrentDomain.FriendlyName;

            // TODO: Make this an option? Add Option to sort assemblies as well?
            testAssembly.Sort();

            return testAssembly;
        }
        private void BuildTestSuiteTree(MethodInfo method, ref TestSuite testSuite, HierachyNode hierachyNode)
        {
            NUnitFramework.ApplyCommonAttributes(method, testSuite);
            //try
            //{
            //    NUnitFramework.ApplyCommonAttributes(method, testSuite);
            //}
            //catch
            //{
            //}
            foreach (DictionaryEntry entry in hierachyNode.Properties)
            {
                if (entry.Value is HierachyNodeProperty)
                {
                    HierachyNodeProperty prop = entry.Value as HierachyNodeProperty;
                    testSuite.Properties[entry.Key] = prop.Value;
                    if (string.IsNullOrEmpty(prop.Description) == false)
                    {
                        string key = string.Format(
                            "{0}_{1}",
                            HierachyNode.DESCRIPTION,
                            prop.Description);
                        testSuite.Properties[entry.Key] = prop.Value;
                    }
                }
                else
                {
                    testSuite.Properties[entry.Key] = entry.Value;
                }
            }

            if (hierachyNode.Nodes.Count > 0)
            {
                for (int index = 0; index < hierachyNode.Nodes.Count; index++)
                {
                    HierachyNode childNode = (HierachyNode)hierachyNode.Nodes[index];
                    TestSuite childTestSuite = new TestSuite(childNode.Name);
                    this.BuildTestSuiteTree(method, ref childTestSuite, childNode);
                    testSuite.Add(childTestSuite);
                }
            }
            else
            {
                ParameterizedMethodSuite methodSuite
                    = NUnitTestCaseBuilder.BuildParameterizedMethodSuite(method, testSuite)
                    as ParameterizedMethodSuite;

                if (methodSuite != null)
                {
                    if (methodSuite.Tests.Count > 0)
                    {
                        foreach (TestT item in methodSuite.Tests)
                        {
                            testSuite.Add(item);

                        }
                    }
                    else
                    {
                        //methodSuite..TestName = testSuite.TestName;
                        testSuite = methodSuite;
                    }
                }
            }
        }
Beispiel #27
0
        public static TestSuite suite()
        {
            TestSuite suite = new TestSuite("OpenPGP Example Tests");

            suite.Add(new AllTests());

            return suite;
        }
Beispiel #28
0
        /// <summary>
        /// Build a suite based on a TestPackage
        /// </summary>
        /// <param name="package">The TestPackage</param>
        /// <returns>A TestSuite</returns>
        public TestSuite Build(TestPackage package)
        {
            bool autoNamespaceSuites = package.GetSetting("AutoNamespaceSuites", true);
            bool mergeAssemblies     = package.GetSetting("MergeAssemblies", false);

            TestContext.TestCaseTimeout = package.GetSetting("DefaultTimeout", 0);

            if (package.IsSingleAssembly)
            {
                return(BuildSingleAssembly(package));
            }
            string targetAssemblyName = null;

            if (package.TestName != null && package.Assemblies.Contains(package.TestName))
            {
                targetAssemblyName = package.TestName;
                package.TestName   = null;
            }

            TestSuite            rootSuite     = new TestSuite(package.FullName);
            NamespaceTreeBuilder namespaceTree =
                new NamespaceTreeBuilder(rootSuite);

            builders.Clear();
            foreach (string assemblyName in package.Assemblies)
            {
                if (targetAssemblyName == null || targetAssemblyName == assemblyName)
                {
                    TestAssemblyBuilder builder = new TestAssemblyBuilder();
                    builders.Add(builder);

                    Test testAssembly = builder.Build(assemblyName, package.TestName, autoNamespaceSuites && !mergeAssemblies);

                    if (testAssembly != null)
                    {
                        if (!mergeAssemblies)
                        {
                            rootSuite.Add(testAssembly);
                        }
                        else if (autoNamespaceSuites)
                        {
                            namespaceTree.Add(testAssembly.Tests);
                            rootSuite = namespaceTree.RootSuite;
                        }
                        else
                        {
                            foreach (Test test in testAssembly.Tests)
                            {
                                rootSuite.Add(test);
                            }
                        }
                    }
                }
            }

            if (rootSuite.Tests.Count == 0)
            {
                return(null);
            }

            return(rootSuite);
        }
Beispiel #29
0
		private RowTestCase CreateRowTestCase(TestClass fixture, string methodName, params object[] arguments)
		{
			MethodInfo method = GetTestClassMethod(methodName);
			
			NUnitTestFixture nunitTestFixture = new NUnitTestFixture(fixture.GetType());
			nunitTestFixture.Fixture = fixture;
			
			TestSuite suite = new TestSuite(nunitTestFixture.TestName.Name, method.Name);
			suite.Parent = nunitTestFixture;
			suite.Fixture = fixture;

			RowTestCase testCase = new RowTestCase(method, method.Name, arguments);
			testCase.Fixture = fixture;
			suite.Add(testCase);
			
			return testCase;
		}