コード例 #1
0
ファイル: TestExtenderGraph.cs プロジェクト: dotnet/wpf-test
        ///<summary>
        ///</summary>
        public TestExtenderOutput Generate(int rootIndex)
        {
            TestExtenderOutput txro = new TestExtenderOutput();

            Stopwatch timer = Stopwatch.StartNew();

            CalculateDependenciesAndRoots();

            if (rootIndex >= this.Generators.Count || rootIndex < 0)
            {
                throw new ArgumentOutOfRangeException("rootIndex");
            }

            IVariationGenerator vg = this.RootGenerators[rootIndex];

            foreach (VariationItem item in vg.Generate())
            {
                item.IsRoot = true;
                txro.TestCases.Add(item);
            }

            timer.Stop();
            GlobalLog.LogDebug("Generation Time " + rootIndex.ToString() + " : " + timer.Elapsed.TotalSeconds.ToString());

            return(txro);
        }
コード例 #2
0
ファイル: TestExtenderHelper.cs プロジェクト: dotnet/wpf-test
        private static string WriteCache(string file, TestExtenderOutput txro)
        {
            string path     = Path.GetDirectoryName(file);
            string fileName = Path.GetFileNameWithoutExtension(file);

            fileName = fileName + ".txro";
            fileName = Path.Combine(path, fileName);
            txro.Save(fileName);
            file = fileName;
            return(file);
        }
コード例 #3
0
ファイル: TestExtenderGraph.cs プロジェクト: dotnet/wpf-test
        ///<summary>
        ///</summary>
        public TestExtenderOutput Generate()
        {
            TestExtenderOutput txro = new TestExtenderOutput();

            Stopwatch timer = Stopwatch.StartNew();

            CalculateDependenciesAndRoots();

            for (int i = 0; i < RootGenerators.Length; i++)
            {
                TestExtenderOutput.MergeTEO(txro, Generate(i));
            }

            timer.Stop();
            GlobalLog.LogDebug("Generation Total Time: " + timer.Elapsed.TotalSeconds.ToString());

            return(txro);
        }
コード例 #4
0
ファイル: TestExtenderHelper.cs プロジェクト: dotnet/wpf-test
        /// <summary>
        /// Loads a TestExterderGraph or TestExtenderOutput file string.
        /// </summary>
        /// <param name="file"></param>
        /// <param name="createCache"></param>
        /// <returns>
        /// Microsoft.Test.TestExterderOutput object. Null if the file is not a TXRO or TXR.
        /// </returns>
        public static TestExtenderOutput LoadFile(ref string file, bool createCache)
        {
            if (string.IsNullOrEmpty(file))
            {
                throw new ArgumentException("Argument cannot be null or empty string.", "file");
            }

            if (!File.Exists(file))
            {
                throw new ArgumentException("The file does not exist.", "file");
            }

            TestExtenderOutput txro = null;

            try
            {
                TestExtenderFileTypes fileType = GetTypeOfFile(file);

                if (fileType == TestExtenderFileTypes.TestExtenderOutput)
                {
                    txro = TestExtenderOutput.Load(file);
                }
                else if (fileType == TestExtenderFileTypes.TestExtenderGraph)
                {
                    TestExtenderGraph txr = TestExtenderGraph.Load(file);
                    txro = txr.Generate();
                    // file = WriteCache(file, txro);
                }
            }
            catch (Exception e)
            {
                GlobalLog.LogStatus(e.ToString());
                txro = null;
            }

            if (txro == null)
            {
                GlobalLog.LogStatus("A TestExtender cannot be loaded. There could be missing test cases. File: " + file);
            }

            return(txro);
        }
コード例 #5
0
ファイル: TestExtenderOutput.cs プロジェクト: dotnet/wpf-test
        /// <summary>
        ///
        /// </summary>
        /// <param name="testCase"></param>
        /// <returns></returns>
        public string Save(int testCase)
        {
            if (_testCases.Count == 0)
            {
                return("");
            }

            if (testCase >= _testCases.Count)
            {
                throw new IndexOutOfRangeException();
            }

            // Copy single case to new empty TXRO.
            // Mark single case as NOT root so the TestContract
            // values will not be serialized.
            TestExtenderOutput txro = new TestExtenderOutput();
            VariationItem      item = this.TestCases[testCase];

            item.IsRoot = false;
            txro.TestCases.Add(item);

            return(XamlWriter.Save(txro));
        }
コード例 #6
0
ファイル: TestExtenderOutput.cs プロジェクト: dotnet/wpf-test
 /// <summary>
 ///
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="source"></param>
 static internal void MergeTEO(TestExtenderOutput destination, TestExtenderOutput source)
 {
     destination.TestCases.AddRange(source.TestCases);
 }