public TestScriptObjectContainer(TestScriptObjectContainer originalTestScriptObjectContainer, TestScriptObjectContainer parent)
            : base(originalTestScriptObjectContainer, parent)
        {
            _functionalArea = TestUtils.SafeCopyString(originalTestScriptObjectContainer._functionalArea);
            _reference      = TestUtils.SafeCopyString(originalTestScriptObjectContainer._reference);
            _author         = Environment.UserName;
            _created        = originalTestScriptObjectContainer._created;

            _testProperties = new TestPropertyCollection();

            foreach (TestProperty testProperty in originalTestScriptObjectContainer._testProperties)
            {
                _testProperties.Add(new TestProperty(testProperty));
            }

            _testScriptObjects = new TestScriptObjectCollection();

            foreach (TestScriptObject testScriptObject in originalTestScriptObjectContainer._testScriptObjects)
            {
                TestScriptObject newObject = null;

                if (testScriptObject is TestSuite)
                {
                    newObject = new TestSuite((TestSuite)testScriptObject, null, (TestSuite)this);
                }
                else if (testScriptObject is TestCase)
                {
                    newObject = new TestCase((TestCase)testScriptObject, (TestSuite)this);
                }
                else if (testScriptObject is TestStep)
                {
                    newObject = new TestStep((TestStep)testScriptObject, (TestCase)this);
                }

                _testScriptObjects.Add(newObject);
            }
        }
Ejemplo n.º 2
0
        public static TestSuite ReadFromOldFileFormat(string filePath, TestSuite parent = null)
        {
            TestSuite testSuite = DeserializeFromFile(filePath);
            //testSuite._filePath = filePath;

            //// If pre or post processor is defined, need to expand it its path.
            //if (null != testSuite.TestPreprocessor.TestAutomationDefinition.TestAssembly)
            //{
            //    Core.TestProperties.ExpandString(testSuite.TestPreprocessor.TestAutomationDefinition.TestAssembly);
            //}

            //if (null != testSuite.TestPostprocessor.TestAutomationDefinition.TestAssembly)
            //{
            //    Core.TestProperties.ExpandString(testSuite.TestPostprocessor.TestAutomationDefinition.TestAssembly);
            //}

            TestScriptObjectCollection testScriptObjects = new TestScriptObjectCollection();

            foreach (TestScriptObject testObject in testSuite.TestScriptObjects)
            {
                if (testObject is TestSuite)
                {
                    // If child is suite, need expand file path so can be loaded (i.e., deserialized)
                    TestSuite childSuite       = testObject as TestSuite;
                    string    expandedFilePath = Core.TestProperties.ExpandString(childSuite._filePath);
                    //childSuite = DeserializeFromFile(expandedFilePath);
                    childSuite = ReadFromOldFileFormat(expandedFilePath);

                    // Need to expand pre and post processor test assembly paths.
                    //if (null != childSuite.TestPreprocessor.TestAutomationDefinition.TestAssembly)
                    //{
                    //    Core.TestProperties.ExpandString(childSuite.TestPreprocessor.TestAutomationDefinition.TestAssembly);
                    //}

                    //if (null != childSuite.TestPostprocessor.TestAutomationDefinition.TestAssembly)
                    //{
                    //    Core.TestProperties.ExpandString(childSuite.TestPostprocessor.TestAutomationDefinition.TestAssembly);
                    //}

                    testScriptObjects.Add(childSuite);
                }
                else if (testObject is TestCase)
                {
                    TestCase testCase = testObject as TestCase;

                    foreach (TestStep testStep in testCase.TestSteps)
                    {
                        var definition = testStep.TestAutomationDefinition;

                        if (definition.TestAssembly != null)
                        {
                            // Expand test assembly path for execution.
                            definition.TestAssembly = Core.TestProperties.FixupString(definition.TestAssembly, "TestAssemblies");
                        }
                    }

                    testScriptObjects.Add(testObject);
                }
            }

            testSuite._testScriptObjects = testScriptObjects;

            return(testSuite);
        }