Ejemplo n.º 1
0
        public static void RunTests(TestContext context)
        {
            TestRunner.EnableWaitStatus("Beginning Tests");

            int _numTests = context.QueryCombinations;
            if (_numTests < cTrivialNumberOfTestsLimit)
            {
                var filesToRun = WriteAllTestCasesToFile(context);

                TestRunner.EnableWaitStatus("Running Test Cases");
                var fileResults = RunTestCases(filesToRun, context.Server);

                TestRunner.EnableWaitStatus("Displaying Differences");
                _diffEngine.CompareFiles(fileResults);
            }
            else
            {
                List<ComparisonPair> results = new List<ComparisonPair>();
                int threads = 0, completed = 0;

                TestRunner.EnableWaitStatus("Running Test Cases");
                foreach (var pair in WriteTestCasesToFile(context))
                {
                    threads++;
                    ThreadPool.QueueUserWorkItem(delegate(object data)
                    {
                        var tmp = RunTestCases(pair, context.Server);
                        lock (results)
                            results.Add(tmp);
                        Interlocked.Increment(ref completed);
                    });
                }
                while (completed != threads) Thread.Sleep(100);
                if (results.Count != completed) throw new WTFException();

                for (int i = 0; i < completed; i++)
                {
                    TestRunner.EnableWaitStatus("Displaying Differences " + i + " of " + completed);
                    _diffEngine.CompareFiles(results[i]);
                }
            }

            TestRunner.DisableWaitStatus();
        }
Ejemplo n.º 2
0
        public MainWindow()
        {
            CurrentContext = new TestContext();
            TestRunner.EnableWaitStatus = delegate(string msg)
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    this.EnableWaitStatus(msg);
                }));
            };
            TestRunner.DisableWaitStatus = delegate()
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    this.DisableWaitStatus();
                }));
            };

            InitializeComponent();
            InitializeImageResources();
            DisableWaitStatus();
            ThreadPool.QueueUserWorkItem(CheckUpdateStatus);
        }
Ejemplo n.º 3
0
        private static ComparisonPair WriteTestCasesToFile(TestContext context, int offset, int limit)
        {
            string filenameOld = "", filenameNew = "";

            var root = Path.GetTempFileName();
            MainWindow.TemporaryFilesCreated.Add(root);
            root = root.ReplaceLast(".tmp", "");
            filenameOld = root + ".old.txt";
            filenameNew = root + ".new.txt";
            MainWindow.TemporaryFilesCreated.Add(filenameOld);
            MainWindow.TemporaryFilesCreated.Add(filenameNew);

            var testCases = context.TestCases;

            var oldHndl = new StreamWriter(filenameOld, false);
            var newHndl = new StreamWriter(filenameNew, false);
            oldHndl.WriteLine("Use " + context.Database + ";");
            newHndl.WriteLine("Use " + context.Database + ";");

            for (int i = 0; i < testCases.Count; i++)
            {
                if (i < offset) continue;
                if (i > (offset + limit) && limit > 0) break;

                var paramString = testCases[i].GetParameterString();
                var paramStringEscaped = paramString.Replace("'", "''");

                oldHndl.WriteLine("print '" + paramStringEscaped + "'");
                newHndl.WriteLine("print '" + paramStringEscaped + "'");

                oldHndl.WriteLine(string.Format("exec {0} {1}", context.ComparisonProc, paramString));
                newHndl.WriteLine(string.Format("exec {0} {1}", context.StoredProcedure, paramString));
            }
            oldHndl.Close();
            newHndl.Close();

            return new ComparisonPair(filenameOld, filenameNew);
        }
Ejemplo n.º 4
0
        private static IEnumerable<ComparisonPair> WriteTestCasesToFile(TestContext context)
        {
            int _numTests = context.QueryCombinations;
            int testsPerCycle = GetNumTestsPerFile();

            for (int i = 0; i < _numTests; i += testsPerCycle)
            {
                yield return WriteTestCasesToFile(context, i, testsPerCycle);
            }
        }
Ejemplo n.º 5
0
 private static ComparisonPair WriteAllTestCasesToFile(TestContext context)
 {
     return WriteTestCasesToFile(context, 0, -1);
 }