Пример #1
0
 public CallableTest(TestFunc func, MachineInitFunc initFunc, IDictionary <string, string> planArguments, IJSTestProvider provider)
 {
     this.provider      = provider;
     this.planArguments = planArguments;
     this.func          = func;
     this.initFunc      = initFunc;
 }
Пример #2
0
 public CallableTest(TestFunc func, MachineInitFunc initFunc, IDictionary<string, string> planArguments, IJSTestProvider provider)
 {
     this.provider = provider;
     this.planArguments = planArguments;
     this.func = func;
     this.initFunc = initFunc;
 }
Пример #3
0
 private static void Iterate(TestFunc func)
 {
     for (int i = 0; i < Count; i++)
     {
         _ = func(i);
     }
 }
Пример #4
0
        public static void Main()
        {
            TestFunc testFunc = new TestFunc();

            WindowManager.graphWindow.graphs.Add(new FuncGraph(testFunc));
            WindowManager.render();
        }
Пример #5
0
 public void AddChild(TestFunc myFunction, int priority, string description, params object[] paramList)
 {
     TestVariation myVariation = new TestVariation(myFunction);
     VariationAttribute myAttribute = new VariationAttribute(description, paramList);
     myAttribute.Priority = priority;
     myVariation.Attribute = myAttribute;
     this.AddChild(myVariation);
 }
Пример #6
0
 public CVariation(CTestCase testcase, string desc, TestFunc function)
     : base(null, desc)
 {
     //Note: The parent automatically gets setup on AddVariation so we don't 
     //really need to pass in the testcase, left here for backward compatibilty 
     //of inherited drivers.
     _pfunc = function;
 }
Пример #7
0
 void VariationsForXAttribute(TestFunc func)
 {
     AddChild(func, 0, "Only attribute", new XAttribute[] { new XAttribute("xxx", "yyy") });
     AddChild(func, 0, "Only attribute with namespace", new XAttribute[] { new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 0, "Mulitple attributes", new XAttribute[] { new XAttribute("xxx", "yyy"), new XAttribute("a", "aa") });
     AddChild(func, 0, "Multiple attributes with namespace", new XAttribute[] { new XAttribute("{b}xxx", "b_yyy"), new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 0, "IEnumerable of XAttributes", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes().ToArray());
 }
Пример #8
0
 void VariationsForXAttribute(TestFunc func)
 {
     AddChild(func, 0, "XAttribute - only attribute", new XAttribute[] { new XAttribute("xxx", "yyy") }, 0);
     AddChild(func, 0, "XAttribute - only attribute with namespace", new XAttribute[] { new XAttribute("{a}xxx", "a_yyy") }, 0);
     AddChild(func, 0, "XAttribute - mulitple attributes", new XAttribute[] { new XAttribute("xxx", "yyy"), new XAttribute("a", "aa") }, 1);
     AddChild(func, 1, "XAttribute - multiple attributes with namespace", new XAttribute[] { new XAttribute("{b}xxx", "b_yyy"), new XAttribute("{a}xxx", "a_yyy") }, 0);
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes().ToArray(), 10);
 }
Пример #9
0
 void VariationsForXDocument(TestFunc func)
 {
     AddChild(func, 0, "XDocument - empty element", new XElement("element"));
     AddChild(func, 0, "XDocument - element with child", new XElement("parent", new XElement("child", "child text")));
     AddChild(func, 0, "XDocument - document type", new XDocumentType("root", "", "", ""));
     AddChild(func, 0, "XDocument - PI", new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XDocument - comment", new XComment("Comment"));
 }
Пример #10
0
 void VariationsForRemove(TestFunc func)
 {
     AddChild(func, 1, "Remove - Empty element", new XElement("element"));
     AddChild(func, 0, "Remove - Element with value", new XElement("element", "value"));
     AddChild(func, 0, "Remove - Element with attribute", new XElement("element", new XAttribute("a", "aa")));
     AddChild(func, 0, "Remove - Element with child", new XElement("parent", new XElement("child", "child text")));
     AddChild(func, 1, "Remove - Element with nodes", new XElement("nodes", InputSpace.GetElement(100, 10).DescendantNodes()));
 }
Пример #11
0
 void VariationsForValue(TestFunc func)
 {
     AddChild(func, 1, "Value - Empty element", new XElement("element"), (double)10);
     AddChild(func, 0, "Value - Element with value", new XElement("element", "value"), "newValue");
     AddChild(func, 0, "Value - Element with attribute", new XElement("element", new XAttribute("a", "aa")), System.DateTime.Now);
     AddChild(func, 0, "Value - Element with child", new XElement("parent", new XElement("child", "child text")), "Windows 8");
     AddChild(func, 1, "Value - Element with nodes", new XElement("nodes", InputSpace.GetElement(100, 10).DescendantNodes()), "StackTrace");//Environment.StackTrace);
 }
Пример #12
0
 public CVariation(CTestCase testcase, string desc, TestFunc function)
     : base(null, desc)
 {
     //Note: The parent automatically gets setup on AddVariation so we don't
     //really need to pass in the test case, left here for backward compatibility
     //of inherited drivers.
     _pfunc = function;
 }
Пример #13
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "Empty element, String", new XElement("element"), "newValue");
     AddChild(func, 0, "String, String", new XElement("element", "value"), "newValue");
     AddChild(func, 0, "Element with attributes, String", new XElement("element", new XAttribute("a", "aa")), "newValue");
     AddChild(func, 0, "Element with child, String", new XElement("parent", new XElement("child", "child text")), "newValue");
     AddChild(func, 1, "Element with nodes", new XElement("root", InputSpace.GetElement(100, 10).DescendantNodes()), "newValue");
 }
Пример #14
0
 MgdDbgTestFuncInfo(string label, string desc, string categoryStr, TestFunc func, TestType tType)
 {
     m_label           = label;
     m_desc            = desc;
     m_isCategoryBased = true;
     m_categoryStr     = categoryStr;
     m_testFunc        = func;
     m_testType        = tType;
 }
Пример #15
0
 public RevitLookupTestFuncInfo(string label, string desc, System.Type classType, TestFunc func, TestType tType)
 {
     m_label = label;
     m_desc = desc;
     m_classType = classType;
     m_isCategoryBased = false;
     m_testFunc = func;
     m_testType = tType;
 }
Пример #16
0
 RevitLookupTestFuncInfo(string label, string desc, System.Type classType, TestFunc func, TestType tType)
 {
     m_label           = label;
     m_desc            = desc;
     m_classType       = classType;
     m_isCategoryBased = false;
     m_testFunc        = func;
     m_testType        = tType;
 }
Пример #17
0
 void VariationsForXDocument(TestFunc func)
 {
     AddChild(func, 1, "XDocument - empty element", new XNode[] { new XElement("element") }, 0);
     AddChild(func, 0, "XDocument - element with child", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, 0);
     AddChild(func, 0, "XDocument - document type", new XNode[] { new XDocumentType("root", "", "", "") }, 0);
     AddChild(func, 0, "XDocument - PI", new XNode[] { new XProcessingInstruction("PI", "Data") }, 0);
     AddChild(func, 0, "XDocument - comment", new XNode[] { new XComment("Comment") }, 0);
     AddChild(func, 1, "XDocument - text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 1);
 }
Пример #18
0
                public void AddChild(TestFunc myFunction, int priority, string description, params object[] paramList)
                {
                    TestVariation      myVariation = new TestVariation(myFunction);
                    VariationAttribute myAttribute = new VariationAttribute(description, paramList);

                    myAttribute.Priority  = priority;
                    myVariation.Attribute = myAttribute;
                    this.AddChild(myVariation);
                }
Пример #19
0
 void VariationsForXDocument(TestFunc func)
 {
     AddChild(func, 0, "XDocument - empty element before comment", new XNode[] { new XElement("element") }, new XComment("Comment"));
     AddChild(func, 0, "XDocument - element before PI", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XDocument - document type before element", new XNode[] { new XDocumentType("root", "", "", "") }, new XElement("root"));
     AddChild(func, 0, "XDocument - PI before text", new XNode[] { new XProcessingInstruction("PI", "Data") }, new XText(" "));
     AddChild(func, 0, "XDocument - comment before document type", new XNode[] { new XComment("Comment") }, new XDocumentType("root", "", "", ""));
     AddChild(func, 1, "XDocument - text before text", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, new XText(" "));
 }
Пример #20
0
 void VariationsForXAttribute(TestFunc func)
 {
     AddChild(func, 0, "XAttribute - attribute in element with no attributes", new XAttribute[] { new XAttribute("xxx", "yyy") }, null);
     AddChild(func, 0, "XAttribute - attribute with namespace in element with no attributes", new XAttribute[] { new XAttribute("{a}xxx", "a_yyy") }, null);
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes in element with no attributes", InputSpace.GetElement(100, 10).Attributes().ToArray(), null);
     AddChild(func, 0, "XAttribute - attribute in element with attribute", new XAttribute[] { new XAttribute("xxx", "yyy") }, new XAttribute("a", "aa"));
     AddChild(func, 0, "XAttribute - attribute with namespace in element with attributes", new XAttribute[] { new XAttribute("{b}xxx", "b_yyy") }, new XAttribute("a", "aa"));
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes in element with no attributes", InputSpace.GetElement(100, 10).Attributes().ToArray(), new XAttribute("a", "aa"));
 }
Пример #21
0
 public RevitLookupTestFuncInfo(string label, string desc, string categoryStr, TestFunc func, TestType tType)
 {
     m_label = label;
     m_desc = desc;
     m_classType = null;
     m_isCategoryBased = true;
     m_categoryStr = categoryStr;
     m_testFunc = func;
     m_testType = tType;
 }
Пример #22
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element, text", new XElement("element"), new XText(" "));
     AddChild(func, 0, "XElement - element with attribtue, text", new XElement("element", new XAttribute("a", "aa")), new XText(""));
     AddChild(func, 0, "XElement - element, empty element", new XElement("parent", new XElement("child", "child text")), new XElement("element"));
     AddChild(func, 0, "XElement - CData, comment", new XCData("x+y >= z-m"), new XComment("Comment"));
     AddChild(func, 0, "XElement - PI, element with attribute", new XProcessingInstruction("PI", "Data"), new XElement("element", new XAttribute("a", "aa")));
     AddChild(func, 0, "XElement - comment, text", new XComment("Comment"), new XText("\t"));
     AddChild(func, 0, "XElement - text node, element", new XText("\t"), XElement.Parse(@"<a></a>"));
 }
Пример #23
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element before text", new XNode[] { new XElement("element") }, new XText("some text"));
     AddChild(func, 0, "XElement - element before PI", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XElement - CData before element", new XNode[] { new XCData("x+y >= z-m") }, new XElement("child"));
     AddChild(func, 0, "XElement - PI before text", new XNode[] { new XProcessingInstruction("PI", "Data") }, new XText(" "));
     AddChild(func, 0, "XElement - comment before CData", new XNode[] { new XComment("Comment") }, new XCData("x+y >= z-m"));
     AddChild(func, 1, "XElement - text before empty text", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, new XText(" "));
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray(), new XText(".."));
 }
Пример #24
0
        public void Action1()
        {
            DelegateTest3 t  = new DelegateTest3();
            TestFunc      t1 = t.Test1;
            TestFunc      t2 = t.Test2;

            t1 += t2;
            t2(40);
            t1(40);
        }
Пример #25
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element, text", new XElement("element"), new XText(" "));
     AddChild(func, 0, "XElement - element with attribtue, text", new XElement("element", new XAttribute("a", "aa")), new XText(""));
     AddChild(func, 0, "XElement - element, empty element", new XElement("parent", new XElement("child", "child text")), new XElement("element"));
     AddChild(func, 0, "XElement - CData, comment", new XCData("x+y >= z-m"), new XComment("Comment"));
     AddChild(func, 0, "XElement - PI, element with attribute", new XProcessingInstruction("PI", "Data"), new XElement("element", new XAttribute("a", "aa")));
     AddChild(func, 0, "XElement - comment, text", new XComment("Comment"), new XText("\t"));
     AddChild(func, 0, "XElement - text node, element", new XText("\t"), XElement.Parse(@"<a></a>"));
 }
 // helper function to layout a button, it's test function, and a status label that goes next to it
 void GuiButtonTestStatus( string buttonText, TestFunc testFunc, string statusText )
 {
     GUILayout.BeginHorizontal();
     if(GUILayout.Button(buttonText, GUILayout.Width(250), GUILayout.Height(20) ))
     {
         testFunc();
     }
     GUILayout.Label( statusText );
     GUILayout.EndHorizontal();
 }
Пример #27
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element before text", new XNode[] { new XElement("element") }, new XText("some text"));
     AddChild(func, 0, "XElement - element before PI", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XElement - CData before element", new XNode[] { new XCData("x+y >= z-m") }, new XElement("child"));
     AddChild(func, 0, "XElement - PI before text", new XNode[] { new XProcessingInstruction("PI", "Data") }, new XText(" "));
     AddChild(func, 0, "XElement - comment before CData", new XNode[] { new XComment("Comment") }, new XCData("x+y >= z-m"));
     AddChild(func, 1, "XElement - text before empty text", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, new XText(" "));
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray(), new XText(".."));
 }
Пример #28
0
 RevitLookupTestFuncInfo(string label, string desc, string categoryStr, TestFunc func, TestType tType)
 {
     m_label           = label;
     m_desc            = desc;
     m_classType       = null;
     m_isCategoryBased = true;
     m_categoryStr     = categoryStr;
     m_testFunc        = func;
     m_testType        = tType;
 }
Пример #29
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element I", XElement.Parse(@"<a></a>"));
     AddChild(func, 0, "XElement - empty element II", new XElement("element"));
     AddChild(func, 0, "XElement - element with child", new XElement("parent", new XElement("child", "child text")));
     AddChild(func, 0, "XElement - CData", new XCData("x+y >= z-m"));
     AddChild(func, 0, "XElement - PI", new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XElement - comment", new XComment("Comment"));
     AddChild(func, 0, "XElement - text nodes", new XText(""));
 }
Пример #30
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 1, "XElement - empty element", new XNode[] { new XElement("element") }, 0);
     AddChild(func, 0, "XElement - first element", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, 0);
     AddChild(func, 0, "XElement - last element", new XNode[] { new XElement("parent", "parent text"), new XElement("child", "child text") }, 1);
     AddChild(func, 0, "XElement - middle node", new XNode[] { new XElement("parent", "parent text"), new XText("text"), new XElement("child", "child text") }, 1);
     AddChild(func, 0, "XElement - CData", new XNode[] { new XCData("x+y >= z-m") }, 0);
     AddChild(func, 0, "XElement - PI", new XNode[] { new XProcessingInstruction("PI", "Data") }, 0);
     AddChild(func, 0, "XElement - comment", new XNode[] { new XComment("Comment") }, 0);
     AddChild(func, 0, "XElement - first text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 0);
     AddChild(func, 1, "XElement - second text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 1);
     AddChild(func, 1, "XElement - third text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 2);
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray(), 50);
 }
Пример #31
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 1, "XElement - empty element", new XNode[] { new XElement("element") }, 0);
     AddChild(func, 0, "XElement - first element", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, 0);
     AddChild(func, 0, "XElement - last element", new XNode[] { new XElement("parent", "parent text"), new XElement("child", "child text") }, 1);
     AddChild(func, 0, "XElement - middle node", new XNode[] { new XElement("parent", "parent text"), new XText("text"), new XElement("child", "child text") }, 1);
     AddChild(func, 0, "XElement - CData", new XNode[] { new XCData("x+y >= z-m") }, 0);
     AddChild(func, 0, "XElement - PI", new XNode[] { new XProcessingInstruction("PI", "Data") }, 0);
     AddChild(func, 0, "XElement - comment", new XNode[] { new XComment("Comment") }, 0);
     AddChild(func, 0, "XElement - first text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 0);
     AddChild(func, 1, "XElement - second text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 1);
     AddChild(func, 1, "XElement - third text nodes", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, 2);
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray(), 50);
 }
Пример #32
0
        /*
         * Default function for running a block of code a bunch of times.
         */
        private void DefaultTest(string testName, int sampleSize, int threshold, TestFunc codeToExecute)
        {
            long total = 0;

            m_stopwatch.Reset();
            m_stopwatch.Start();

            codeToExecute();

            m_stopwatch.Stop();
            total = m_stopwatch.ElapsedMilliseconds;

            CheckAgainstNative(testName, total, sampleSize, threshold);
        }
Пример #33
0
 void VariationsForXDocument(TestFunc func)
 {
     AddChild(func, 1, "XDocument - empty element in empty doc", new XNode[] { new XElement("element") }, null);
     AddChild(func, 0, "XDocument - element in empty doc", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, null);
     AddChild(func, 0, "XDocument - document type in empty doc", new XNode[] { new XDocumentType("root", "", "", "") }, null);
     AddChild(func, 0, "XDocument - PI in empty doc", new XNode[] { new XProcessingInstruction("PI", "Data") }, null);
     AddChild(func, 0, "XDocument - comment in empty doc", new XNode[] { new XComment("Comment") }, null);
     AddChild(func, 0, "XDocument - text in empty doc", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, null);
     AddChild(func, 0, "XDocument - empty element in doc with comment", new XNode[] { new XElement("element") }, new XComment("Comment"));
     AddChild(func, 0, "XDocument - element in doc with PI", new XNode[] { new XElement("parent", new XElement("child", "child text")) }, new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XDocument - document type in doc with text", new XNode[] { new XDocumentType("root", "", "", "") }, new XText(" "));
     AddChild(func, 0, "XDocument - PI in doc with text", new XNode[] { new XProcessingInstruction("PI", "Data") }, new XText(" "));
     AddChild(func, 0, "XDocument - comment in doc with element", new XNode[] { new XComment("Comment") }, new XElement("root"));
     AddChild(func, 1, "XDocument - text in doc with empty text", new XNode[] { new XText(""), new XText(" "), new XText("\t") }, new XText(" "));
 }
Пример #34
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 1, "XElement - empty element", new XObject[] { new XElement("element") });
     AddChild(func, 0, "XElement - element with child", new XObject[] { new XElement("parent", new XElement("child", "child text")) });
     AddChild(func, 0, "XElement - CData", new XObject[] { new XCData("x+y >= z-m") });
     AddChild(func, 0, "XElement - PI", new XObject[] { new XProcessingInstruction("PI", "Data") });
     AddChild(func, 0, "XElement - comment", new XObject[] { new XComment("Comment") });
     AddChild(func, 0, "XElement - text nodes", new XObject[] { new XText(""), new XText(" "), new XText("\t") });
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray());
     AddChild(func, 0, "XAttribute - only attribute", new XObject[] { new XAttribute("xxx", "yyy") });
     AddChild(func, 0, "XAttribute - only attribute with namespace", new XObject[] { new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 0, "XAttribute - mulitple attributes", new XObject[] { new XAttribute("xxx", "yyy"), new XAttribute("a", "aa") });
     AddChild(func, 1, "XAttribute - multiple attributes with namespace", new XObject[] { new XAttribute("{b}xxx", "b_yyy"), new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes().ToArray());
     AddChild(func, 1, "Mixed - Nodes and attributes", new XObject[] { new XAttribute("{b}xxx", "b_yyy"), new XElement("parent", new XElement("child", "child text")) });
 }
Пример #35
0
        static void TestInputs(FileInfo inputsFile, TestFunc test, SearchMode mode = SearchMode.TreeSearch)
        {
            var inputs = File.ReadAllLines(inputsFile.FullName);

            foreach (var inputFileName in inputs.Where(s => !s.StartsWith("#")))
            {
                Console.WriteLine("-------------------------------------------------------------");
                Console.WriteLine($"Running: {inputFileName}");

                var watch = Stopwatch.StartNew();
                test(Path.Combine(inputsFile.Directory.FullName, inputFileName), mode);
                watch.Stop();

                Console.WriteLine($"Time: {watch.Elapsed}");
            }
        }
Пример #36
0
        public void TestSolvers()
        {
            IObjectiveFunction objFun = new TestFunc();

            foreach (ISolver1D solver in _solvers)
            {
                foreach (double accuracy in _accuracies)
                {
                    string testMsg = $"{solver}, accuracy={accuracy:e1}";
                    double root    = solver.Solve(objFun, accuracy, 1.09, 0.1);
                    Assert.AreEqual(root, 1.0, accuracy, testMsg);
                    root = solver./*Bracketed*/ Solve(
                        objFun, accuracy, 0.9, 0.0, 1.0);
                    Assert.AreEqual(root, 1.0, accuracy, testMsg + " (bracketed)");
                }
            }
        }
Пример #37
0
 private void Start()
 {
     if (myDelegate == null)
     {
         Debug.Log("Delegate is initially null!");
     }
     myDelegate = functionOne;
     if (myDelegate == null)
     {
         Debug.Log("Delegate is null after 1!");
     }
     myDelegate -= functionOne;
     if (myDelegate == null)
     {
         Debug.Log("Delegate is null after 2!");
     }
 }
Пример #38
0
        public TestVariation GenerateVariation(TestCase testcase, MethodInfo method)
        {
            TestVariation rcTestVariation;
            TestFunc      testMethodAction = delegate()
            {
                method.Invoke(testcase, null);
            };

            rcTestVariation = new TestVariation(testMethodAction);

            rcTestVariation.Params   = this.Params;
            rcTestVariation.Param    = this.Param;
            rcTestVariation.Desc     = this.Desc;
            rcTestVariation.Id       = this.Id;
            rcTestVariation.Priority = this.Priority;

            return(rcTestVariation);
        }
Пример #39
0
        public JSTestRunner(string initSnapshotName, IDictionary <string, string> planArguments, IJSTestProvider provider)
        {
            this.ctx              = Context.enter();
            this.provider         = provider;
            this.initSnapshotName = initSnapshotName;
            var tests = provider.GetTestDrivers().SelectMany(d =>
                                                             d.Tests.Select(t => new { Driver = d, Name = t }));

            this.planArguments = planArguments;

            MachineInitFunc initFunc = PossiblyInitializeMachine;

            this.scope = ctx.initStandardObjects();
            foreach (var thisTest in tests)
            {
                var      test = thisTest;
                TestFunc func = delegate(IMachine machine, IDictionary <string, string> arguments, ITestResultBin bin)
                {
                    return(test.Driver.RunTest(test.Name, machine, bin, arguments));
                };

                scope.defineProperty(test.Name, new CallableTest(func, initFunc, planArguments, provider), ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            var jsArgsObject = ctx.newObject(scope);

            foreach (var arg in planArguments)
            {
                jsArgsObject.put(arg.Key, jsArgsObject, arg.Value);
            }

            foreach (var name in new[] { "args", "Args", "ARGS" })
            {
                scope.defineProperty(name, jsArgsObject, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
            }

            scope.defineProperty("Debug", new DebugFunction(), ScriptableObject.READONLY + ScriptableObject.PERMANENT);

            ssFunc = new SnapshotFunction(initFunc, provider);

            scope.defineProperty("Snapshot", ssFunc, ScriptableObject.READONLY + ScriptableObject.PERMANENT);
        }
Пример #40
0
        //Helpers
        protected override void                     DetermineChildren()
        {
            //Delegate (add any nested testcases)
            base.DetermineChildren();

            //Dynamically figure out what functions are variations...
            foreach (MethodInfo method in this.GetType().GetMethods())
            {
                //Loop through the Attributes for method
                foreach (VariationAttribute attr in method.GetCustomAttributes(typeof(VariationAttribute), false /*inhert*/))
                {
                    //Every method that has a [Variation attribute] = a variation
                    //Add this variation to our array
                    TestFunc func = null;
                    try
                    {
                        func = (TestFunc)Delegate.CreateDelegate(typeof(TestFunc), this, method);
                    }
                    catch (Exception e)
                    {
                        e = new TestFailedException("Variation: '" + method + "' doesn't match expected signature of 'void func()', unable to add that variation.", null, null, e);
                        HandleException(e);
                        continue;
                    }

                    TestVariation var = this.CreateVariation(func);
                    attr.Name = func.Method.Name;                       //Name is always the function name (invoke)
                    if (attr.Desc == null)
                    {
                        attr.Desc = attr.Name;
                    }
                    var.Attribute = attr;
                    AddChild(var);
                }
            }

            //Sort
            //Default sort is based upon IComparable of each item
            Children.Sort();
        }
Пример #41
0
        private PICATestFunc ConvertTestFunction(TestFunc func)
        {
            switch (func)
            {
            case TestFunc.Always: return(PICATestFunc.Always);

            case TestFunc.Equal: return(PICATestFunc.Equal);

            case TestFunc.Gequal: return(PICATestFunc.Gequal);

            case TestFunc.Greater: return(PICATestFunc.Greater);

            case TestFunc.Lequal: return(PICATestFunc.Lequal);

            case TestFunc.Less: return(PICATestFunc.Less);

            case TestFunc.Never: return(PICATestFunc.Never);

            case TestFunc.Notequal: return(PICATestFunc.Notequal);

            default: return(PICATestFunc.Greater);
            }
        }
Пример #42
0
 void VariationsForXAttribute(TestFunc func)
 {
     AddChild(func, 0, "XAttribute - attribute in element with no attributes", new XAttribute[] { new XAttribute("xxx", "yyy") }, null);
     AddChild(func, 0, "XAttribute - attribute with namespace in element with no attributes", new XAttribute[] { new XAttribute("{a}xxx", "a_yyy") }, null);
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes in element with no attributes", InputSpace.GetElement(100, 10).Attributes().ToArray(), null);
     AddChild(func, 0, "XAttribute - attribute in element with attribute", new XAttribute[] { new XAttribute("xxx", "yyy") }, new XAttribute("a", "aa"));
     AddChild(func, 0, "XAttribute - attribute with namespace in element with attributes", new XAttribute[] { new XAttribute("{b}xxx", "b_yyy") }, new XAttribute("a", "aa"));
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes in element with no attributes", InputSpace.GetElement(100, 10).Attributes().ToArray(), new XAttribute("a", "aa"));
 }
Пример #43
0
		//Constructor
        public	AstoriaTestVariation(TestFunc method)
			: base(method)
		{
		}
Пример #44
0
 public CVariation(TestFunc func)
     : base(null, null)
 {
     _pfunc = func;
 }
Пример #45
0
 protected override TestVariation CreateVariation(TestFunc func)
 {
     return new AstoriaTestVariation(func);
 }
Пример #46
0
 public static List<IMiniSimDescription> Selection(IMiniSimDescription me, string title, TestFunc onTest, ICollection<SimSelection.ICriteria> criteria, int maxSelection, bool canApplyAll, out bool okayed)
 {
     return new FilteredSelection(onTest).GetSelection(me, title, criteria, maxSelection, canApplyAll, out okayed);
 }
Пример #47
0
 protected FilteredSelection(TestFunc onTest)
 {
     mOnTest = onTest;
 }
Пример #48
0
 protected virtual TestVariation CreateVariation(TestFunc func, string desc)
 {
     //Override if you have a specific variation class
     return new TestVariation(func, desc);
 }
Пример #49
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - Empty element without namespace", new XElement("element"), (XName)"newName");
     AddChild(func, 0, "XElement - Element with namespace", new XElement("parent", new XElement("child", "child text")), (XName)"{b}newName");
 }
Пример #50
0
	public A (TestFunc<int> func)
	{
		func (0);
	}
Пример #51
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 0, "XElement - empty element I", XElement.Parse(@"<a></a>"));
     AddChild(func, 0, "XElement - empty element II", new XElement("element"));
     AddChild(func, 0, "XElement - element with child", new XElement("parent", new XElement("child", "child text")));
     AddChild(func, 0, "XElement - CData", new XCData("x+y >= z-m"));
     AddChild(func, 0, "XElement - PI", new XProcessingInstruction("PI", "Data"));
     AddChild(func, 0, "XElement - comment", new XComment("Comment"));
     AddChild(func, 0, "XElement - text nodes", new XText(""));
 }
Пример #52
0
	public A(TestFunc func)
	{
		func (0);
	}
Пример #53
0
 void Test(TestFunc func, RhinoDoc doc)
 {
   RhinoApp.WriteLine("[TEST START] - " + func.Method.ToString());
   Rhino.Commands.Result rc = func(doc);
   RhinoApp.WriteLine("[TEST DONE] - result = " + rc.ToString());
 }
Пример #54
0
 void VariationsForXElement(TestFunc func)
 {
     AddChild(func, 1, "XElement - empty element", new XObject[] { new XElement("element") });
     AddChild(func, 0, "XElement - element with child", new XObject[] { new XElement("parent", new XElement("child", "child text")) });
     AddChild(func, 0, "XElement - CData", new XObject[] { new XCData("x+y >= z-m") });
     AddChild(func, 0, "XElement - PI", new XObject[] { new XProcessingInstruction("PI", "Data") });
     AddChild(func, 0, "XElement - comment", new XObject[] { new XComment("Comment") });
     AddChild(func, 0, "XElement - text nodes", new XObject[] { new XText(""), new XText(" "), new XText("\t") });
     AddChild(func, 1, "XElement - IEnumerable of XNodes", InputSpace.GetElement(100, 10).DescendantNodes().ToArray());
     AddChild(func, 0, "XAttribute - only attribute", new XObject[] { new XAttribute("xxx", "yyy") });
     AddChild(func, 0, "XAttribute - only attribute with namespace", new XObject[] { new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 0, "XAttribute - mulitple attributes", new XObject[] { new XAttribute("xxx", "yyy"), new XAttribute("a", "aa") });
     AddChild(func, 1, "XAttribute - multiple attributes with namespace", new XObject[] { new XAttribute("{b}xxx", "b_yyy"), new XAttribute("{a}xxx", "a_yyy") });
     AddChild(func, 1, "XAttribute - IEnumerable of XAttributes", InputSpace.GetAttributeElement(10, 1000).Elements().Attributes().ToArray());
     AddChild(func, 1, "Mixed - Nodes and attributes", new XObject[] { new XAttribute("{b}xxx", "b_yyy"), new XElement("parent", new XElement("child", "child text")) });
 }
Пример #55
0
 public void RegisterTarget(TestPoint point, TestFunc func)
 {
     this.testPoints[point] = func;
 }
Пример #56
0
		public	TestVariation(TestFunc func)
			: this(func.Method.Name, func)
		{
		}
Пример #57
0
 public TestVariation(TestFunc func)
     : this(func, null)
 {
 }
Пример #58
0
 public TestVariation(TestFunc func, string desc)
     : base(null, desc, TestType.TestVariation)
 {
     pfunc = func;
 }
Пример #59
0
        protected override void DetermineChildren()
        {
            // Use previous settings if  client partial trust level is not medium
            // We only perform client partial-trust test here
            if (AstoriaTestProperties.ServiceTrustLevel != TrustLevel.Medium || (!this.Name.Contains("Client")))
            {
                base.DetermineChildren();
            }

            else
            {
                AppDomain myDomain = this.GetCustomizedAppDomain();
                ArrayList types = this.GetNestedTypes(this.GetType());
                foreach (Type type in types)
                {
                    //Were only interested in objects that inherit from TestCase.
                    //NOTE: We need to filter other objects, since some internal VB classes throw trying 
                    //to get Attributes
                    if (!type.IsSubclassOf(typeof(TestCase)))
                        continue;

                    //Every class that has a TestCase attribute, IS a TestCase
                    foreach (TestCaseAttribute attr in type.GetCustomAttributes(typeof(TestCaseAttribute), false/*inhert*/))
                    {
                        //Create this class (call the constructor with no arguments)
                        // Create testcase instance in another app domain with desired permission set.
                        TestCase testcase = (TestCase)myDomain.CreateInstanceAndUnwrap(type.Assembly.FullName, type.FullName);

                        if (attr.Name == null)
                            attr.Name = type.Name;
                        testcase.Attribute = attr;
                        this.AddChild(testcase);
                    }
                }

                //Sort
                //Default sort is based upon IComparable of each item
                Children.Sort();
            }


            if (AstoriaTestProperties.RuntimeEnvironment != TestRuntimeEnvironment.CheckinSuites)
            {
                // ensure that we don't get 0/0 = 0% results due to empty test cases
                foreach (TestItem child in this.Children.Cast<TestItem>().Where(c => !Descendents(c).OfType<TestVariation>().Any()))
                {
                    child.Children.Clear();

                    TestFunc func = new TestFunc(delegate() { throw new TestSkippedException("Placeholder"); });
                    TestVariation variation = new TestVariation("Placeholder for module with no tests", func);
                    variation.Attribute = new VariationAttribute("Placeholder for module with no tests")
                    {
                        Id = 1,
                        Implemented = true,
                        Priority = AstoriaTestProperties.MinPriority
                    };

                    variation.Parent = child;
                    child.AddChild(variation);
                }
            }
        }
 private static Tuple<long, long, int> ExecuteTestFunc( TestFunc func, IArrayStrategy array )
 {
     Stopwatch stopwatch;
     var result = func( array, out stopwatch );
     return Tuple.Create( stopwatch.ElapsedTicks, stopwatch.ElapsedMilliseconds, result );
 }