Пример #1
0
        private void UploadALM(string strSelectedScriptName, string strStatus, string strFailureReason, string strJenkinsLog)
        {
            string strSelectedTestSetName = treeViewALM.SelectedNode.Name;

            string             strSelectedTestSetFullPath = BuildPath(treeViewALM.SelectedNode);;
            TestSetTreeManager testSetTreeMgr             = (TestSetTreeManager)conn.TestSetTreeManager;
            TestSetFolder      rootTestSetFolder          = (TestSetFolder)testSetTreeMgr.get_NodeByPath(strSelectedTestSetFullPath);
            List        testSetList = rootTestSetFolder.FindTestSets(strSelectedTestSetName, false, string.Empty);
            IEnumerator enumerator  = testSetList.GetEnumerator();;

            if (enumerator.MoveNext())
            {
                TestSet       testSet       = (TestSet)enumerator.Current;
                TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory;
                ListClass     testList      = (ListClass)tsTestFactory.NewList(string.Empty);

                IEnumerator testListEnum = testList.GetEnumerator();
                while (testListEnum.MoveNext())
                {
                    object item  = testListEnum.Current;
                    TSTest atest = (TSTest)testListEnum.Current;
                    if (atest.TestName.ToLower() == strSelectedScriptName.ToLower())
                    {
                        atest.Status        = strStatus;
                        atest["TC_USER_01"] = strFailureReason;
                        atest["TC_USER_09"] = strJenkinsLog;
                        atest.Post();
                    }
                }
            }
        }
Пример #2
0
        public void RunTestSet(TestSet testSet)
        {
            TSScheduler scheduler = testSet.StartExecution("");

            scheduler.RunAllLocally = true;
            scheduler.Run();
        }
Пример #3
0
 private void ReceiveTestEditMessage(TestSet test)
 {
     this.AddCurrentViewToPrevious();
     this.CurrentViewModel = new TestSetEditViewModel {
         SelectedTest = test
     };
 }
Пример #4
0
        public TestSet AddTestSet(TestSet testSet)
        {
            _appDbContext.Add(testSet);
            _appDbContext.SaveChanges();

            return(testSet);
        }
        public void ExtendedSamplesTest(string template, string[] results, TestSet.TestCase testCase)
        {
            var uriTemplate = new UriTemplate(template);

            foreach (var variable in testCase.TestSet.Variables)
            {
                uriTemplate.SetParameter(variable.Key, variable.Value);
            }

            string result = null;
            ArgumentException aex = null;

            try
            {
                result = uriTemplate.Resolve();

            }
            catch (ArgumentException ex)
            {
                aex = ex;
            }

            if (results[0] == "False")
            {
                Assert.NotNull(aex);
            }
            else
            {
                Assert.True(results.Contains(result));
            }

        }
Пример #6
0
        public TestSetEditViewModel()
        {
            try
            {
                this.selectedTest    = new TestSet();
                this.testSetsModel   = BootStrapper.Resolve <ITestSetsModel>();
                this.categoriesModel = BootStrapper.Resolve <ICategoriesModel>();

                this.items = new ObservableCollection <TestItem>();
                if (this.selectedTest.Items != null)
                {
                    foreach (TestItem item in this.selectedTest.Items)
                    {
                        this.items.Add(item);
                    }
                }
                this.categories       = this.categoriesModel.GetAll();
                this.languages        = this.testSetsModel.GetAllLanguages();
                this.SelectedLanguage = TestLanguage.English;
            }
            catch (Exception ex)
            {
                ApplicationErrorHandler.HandleException(ex);
            }
        }
Пример #7
0
        private void btnRun_Click(object sender, EventArgs e)
        {
            if (this._testCases.Count > 0)
            {
                if (this.lstTestData.SelectedItem != null)
                {
                    TestSet set = TestSet.Standard;
                    if (this.radLoadAndMem.Checked)
                    {
                        set = TestSet.LoadAndMemory;
                    }

                    TestSuite      suite  = new TestSuite(this._testCases, (String)this.lstTestData.SelectedItem, (int)this.numIterations.Value, set);
                    fclsTestRunner runner = new fclsTestRunner(suite);
                    runner.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Please selected Test Data to use...", "Test Data Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                MessageBox.Show("Please create one/more Test Cases...", "Test Case(s) Required", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private void PrepareLabHuffmanTreeTestSets()
        {
            var testSet = new TestSet(new Huffman(), "Lab - Huffman tree");

            //testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, new ArgumentNullException(), "Input validation 1", (string)null));
            //testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, new ArgumentNullException(), "Input validation 2", string.Empty));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "2 unique characters, 2 in total", "ab"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "2 unique characters, 3 in total", "aba"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "2 unique characters, 5 in total", "aabaa"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "2 unique characters, 10 in total", "aaabbababb"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "3 unique characters, 16 in total", "aacabccbcacbcabb"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "words - ala ma kota", "ala ma kota"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "words - polamaniec jezykowy 1", "stol z powylamywanymi nogami"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "words - polamaniec jezykowy 2", "Na wyrewolwerowanym wzgórzu przy wyrewolwerowanym rewolwerowcu leży wyrewolwerowany rewolwer wyrewolwerowanego rewolwerowca"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "words - inwokacja", "litwo ojczyzno moja, ty jestes jak zdrowie"));
            testSet.TestCases.Add(new HuffmanTreeTestCase(1.0, null, "1 unique character", "aaa"));
            var       sb = new StringBuilder();
            const int uniqueCharacters = 127;

            for (int i = 0; i < uniqueCharacters; i++)
            {
                sb.Append('A' + i);
            }
            sb.Append(new string('A', 1 << 23));
            for (int i = 0; i < uniqueCharacters; i++)
            {
                sb.Append('A' + i);
            }
            testSet.TestCases.Add(new HuffmanTreeTestCase(3, null, "8.3 mln characters; 127 unique characters", sb.ToString()));
            TestSets[testSet.Description] = testSet;
        }
Пример #9
0
        public bool UpdateTestSet(TestSet testSet)
        {
            _appDbContext.TestSet.Update(testSet);
            _appDbContext.SaveChanges();

            return(true);
        }
Пример #10
0
        static void Main(string[] args)
        {
            Boolean TestMode = true;

            if (TestMode)
            {
                TestSet.Run();
            }
            else
            {
                // --deletedomain "My Domain Name"
                Parser.Default.ParseArguments <Options>(args)
                .WithParsed <Options>(o =>
                {
                    if (o.Verbose)
                    {
                        Console.WriteLine($"Verbose output enabled. Current Arguments: -v {o.Verbose}");
                        Console.WriteLine("Quick Start Example! App is in Verbose mode!");
                    }
                    else
                    {
                        Console.WriteLine($"Current Arguments: -v {o.Verbose}");
                        Console.WriteLine("Quick Start Example!");
                    }
                });
                Console.ReadKey();
            }
        }
Пример #11
0
 private void ReceiveTestRunMessage(TestSet test)
 {
     this.AddCurrentViewToPrevious();
     this.CurrentViewModel = new RunnerTestSetViewModel {
         Test = test
     };
 }
Пример #12
0
        private void treeViewALM_AfterSelect(object sender, TreeViewEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            if (e.Node.Tag != null)
            {
                if (e.Node.Tag.ToString().ToLower() == "testset")
                {
                    TestSetTreeManager testSetTreeMgr = (TestSetTreeManager)conn.TestSetTreeManager;

                    var           path = BuildPath(e.Node);
                    TestSetFolder rootTestSetFolder = (TestSetFolder)testSetTreeMgr.get_NodeByPath(path);
                    List          testSetList       = rootTestSetFolder.FindTestSets(e.Node.Text, false, string.Empty);
                    IEnumerator   enumerator        = testSetList.GetEnumerator();
                    if (enumerator.MoveNext())
                    {
                        TestSet       testSet       = (TestSet)enumerator.Current;
                        TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory;
                        ListClass     testList      = (ListClass)tsTestFactory.NewList(string.Empty);

                        IEnumerator testListEnum = testList.GetEnumerator();
                        if (dtALMTestDetails == null)
                        {
                            dtALMTestDetails = BuildDataTable();
                        }
                        else
                        {
                            dtALMTestDetails.Clear();
                        }
                        List TSSetFields = tsTestFactory.Fields;
                        while (testListEnum.MoveNext())
                        {
                            DataRow drTestDetails = dtALMTestDetails.NewRow();
                            object  item          = testListEnum.Current;
                            TSTest  atest         = (TSTest)testListEnum.Current;

                            drTestDetails["TestName"]      = atest.TestName;
                            drTestDetails["Status"]        = atest.Status;
                            drTestDetails["FailureReason"] = atest["TC_USER_01"];
                            drTestDetails["JenkinsLog"]    = atest["TC_USER_09"];

                            dtALMTestDetails.Rows.Add(drTestDetails);
                        }
                    }

                    dgvALM.DataSource = dtALMTestDetails;
                }
                else
                {
                    dtALMTestDetails.Clear();
                    dgvALM.DataSource = dtALMTestDetails;
                }
            }
            else
            {
                dtALMTestDetails.Clear();
                dgvALM.DataSource = dtALMTestDetails;
            }
            Cursor.Current = Cursors.Default;
        }
Пример #13
0
        public SinceMutantFilter(IDiffProvider diffProvider = null)
        {
            _logger = ApplicationLogging.LoggerFactory.CreateLogger <SinceMutantFilter>();

            _diffResult = diffProvider.ScanDiff();
            _tests      = diffProvider.Tests;

            if (_diffResult != null)
            {
                _logger.LogInformation("{0} files changed", _diffResult.ChangedSourceFiles?.Count ?? 0 + _diffResult.ChangedTestFiles?.Count ?? 0);

                if (_diffResult.ChangedSourceFiles != null)
                {
                    foreach (var changedFile in _diffResult.ChangedSourceFiles)
                    {
                        _logger.LogInformation("Changed file {0}", changedFile);
                    }
                }
                if (_diffResult.ChangedTestFiles != null)
                {
                    foreach (var changedFile in _diffResult.ChangedTestFiles)
                    {
                        _logger.LogInformation("Changed test file {0}", changedFile);
                    }
                }
            }
        }
        public override void PrepareTestSets()
        {
            TestSet ts;

            ts = TestSets["finalVelocitiesTestsLab"] = new TestSet(new VelocityMeasurements(), "Final velocities lab tests");
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 1", new int[] { 10, 9, 3 }, (2, 22, 3), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 2", new int[] { 0 }, (0, 0, 1), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 3", new int[] { 10 }, (10, 10, 1), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 4", new int[] { 10, 3, 5, 4 }, (2, 22, 4), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 5", new int[] { 4, 11, 5, 5, 5 }, (0, 30, 5), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 6", new int[] { 10, 10, 5, 3, 1 }, (1, 29, 5), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 7", new int[] { 10, 10, 5, 3, 1, 9, 24, 3, 4, 19, 18, 7, 7, 8, 10, 5 }, (1, 143, 16), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 8", new int[] { 7, 10, 2, 18, 4, 6, 6 }, (1, 53, 7), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(20, 1023), (0, 1100, 20), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(100, 1025), (1, 4825, 100), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(100, 12345), (1, 4471, 100), false));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(1000, 12347), (0, 50018, 1000), false));

            ts = TestSets["journeyVelocitiesTestsLab"] = new TestSet(new VelocityMeasurements(), "Journey velocities lab tests");
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 1", new int[] { 10, 9, 3 }, (1, 22, 2), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 2", new int[] { 10 }, (10, 10, 1), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 3", new int[] { 10, 1, 1, 1 }, (7, 13, 4), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 4", new int[] { 10, 3, 5, 4 }, (2, 22, 3), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 5", new int[] { 4, 11, 5, 5, 5 }, (0, 30, 5), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 6", new int[] { 10, 10, 5, 3, 1 }, (0, 29, 2), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 7", new int[] { 5, 7, 10, 23, 55, 2, 1, 23, 9, 0, 8, 4, 1, 24, 86, 5, 6, 100, 353, 4, 5, 67, 32, 45, 23, 34, 56, 32, 23 }, (0, 1043, 8), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(20, 1023), (0, 1100, 7), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(100, 1025), (0, 4825, 12), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(100, 12345), (0, 4471, 7), true));
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test losowy", GenerateTestArray(1000, 12347), (0, 50018, 4), true));
            int[] x = GenerateTestArray(10000, 1234567);
            x[0] = x[1] = 2;
            ts.TestCases.Add(new VelocityMeasurementsTestCase(1, "Test 12", x, (0, 491939, 2), true));
        }
Пример #15
0
        public bool UpdateField(
            int TestSetId,
            string FieldName,
            string Value)
        {
            bool returnValue = false;

            try
            {
                if (!Connect(ServerUrl, Username, Password, Domain, Project))
                {
                    Disconnect();
                    return(false);
                }

                TestSetFactory tsFact = tdc.TestSetFactory;

                TestSet tset = tsFact[TestSetId];

                tset[FieldName] = Value;
                tset.Post();
                returnValue = true;
            }
            catch (COMException ce) { rr.AddErrorLine(HandleException(ce)); }
            finally
            {
                Disconnect();
            }

            return(returnValue);
        }
        public void FiniteSet_Contains()
        {
            var set = new TestSet <int> ();

            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set, 0));
            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set, -1));
            set = new TestSet <int> ()
            {
                9, 3, 1
            };
            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set, 3));
            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set, 1));
            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set, 9));
            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set, 0));
            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set, -1));
            var set2 = new TestSet <string> ()
            {
                "three", "two", "one"
            };

            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set2, "three"));
            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set2, "two"));
            Assert.IsTrue(ReadOnlyFiniteSet.Contains(set2, "one"));
            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set2, ""));
            Assert.IsFalse(ReadOnlyFiniteSet.Contains(set2, null));
        }
Пример #17
0
 public LearningViewModel(TestSet testHeader)
 {
     this.testHeader    = testHeader;
     this.questionNo    = 0;
     this.showFrontSide = true;
     this.DisplayFlashcards();
 }
Пример #18
0
        public RunTests()
        {
            Connect(qcUrl, qcDomain, qcProject, qcLoginName, qcPassword);
            TestSet testSet = GetTestSet(testSetPath, testSetName);

            RunTestSet(testSet);
        }
        // Disabled for the moment. [Theory, PropertyData("FailureSamples")]
        public void FailureSamplesTest(string template, string[] results, TestSet.TestCase testCase)
        {
            var uriTemplate = new UriTemplate(template);

            foreach (var variable in testCase.TestSet.Variables)
            {
                uriTemplate.SetParameter(variable.Key, variable.Value);
            }

            string result = null;
            ArgumentException aex = null;

            try
            {
                result = uriTemplate.Resolve();

            }
            catch (ArgumentException ex)
            {
                aex = ex;
            }

            Assert.NotNull(aex);


        }
Пример #20
0
        public AnfisService(List <DataItem> dataItems, double trainChunk, double minValue, double maxValue, int foldNum) : this()
        {
            if (dataItems.Count == 0)
            {
                throw new Exception("Data items must not be empty");
            }
            if (trainChunk <= 0 || trainChunk >= 1)
            {
                throw  new Exception("Train chunk value must be between 0 and 1");
            }
            if (foldNum <= 1)
            {
                throw new Exception("Number of folds must be greater than 1");
            }

            TrainSet.AddRange(dataItems.GetRange(0, (int)(trainChunk * dataItems.Count)));
            TestSet.AddRange(dataItems.GetRange(
                                 (int)(trainChunk * dataItems.Count), dataItems.Count - (int)(trainChunk * dataItems.Count)));

            TriangularInfoFolds = new TriangularInfo[foldNum];
            var step = (maxValue - minValue) / (foldNum - 1);

            for (int i = 0; i < foldNum; i++)
            {
                TriangularInfoFolds[i] = new TriangularInfo()
                {
                    A = minValue - step + i * step,
                    M = minValue + i * step
                };
            }
        }
Пример #21
0
        public void AddEntityWithNull()
        {
            // Setup
            var set = new TestSet<TestEntity>();

            // Execute
            set.Add(a_item: null);
        }
Пример #22
0
        public void AddEntityWithNull()
        {
            // Setup
            var set = new TestSet <TestEntity>();

            // Execute
            set.Add(a_item: null);
        }
Пример #23
0
        static void Main(string[] args)
        {
            GlobalConfig conf = new GlobalConfig();

            conf.readConfig();

            Session session = new Session(conf);

            IList <IDictionary <string, string> > cases = session.getCases();

            if (cases.Count == 0)
            {
                throw new Exception("No tests found.");
            }

            TestSet ts = new TestSet(session, cases);

            ts.Run();

            /*
             * XmlDocument doc = new XmlDocument();
             * doc.Load("tests.xml");
             *
             * try
             * {
             *  IContext ctx = new Context();
             *  ctx.updateFrom(GlobalConfig.getProperties());
             *
             *  ConnectionFactory.Init();
             *
             *  ITestSet testSet = new TestSet(doc, ctx);
             *
             *
             *  testSet.testStart += testSet_testStart;
             *  testSet.testError += testSet_testError;
             *  testSet.testFinish += testSet_testFinish;
             *
             *  testSet.blockStart +=  testSet_blockStart;
             *  testSet.blockError += testSet_blockError;
             *  testSet.blockFinish += testSet_blockFinish;
             *
             *  testSet.elementStart += testSet_elementStart;
             *  testSet.elementFinish += testSet_elementFinish;
             *  testSet.elementError += testSet_elementError;
             *
             *
             *  bool r = testSet.Run();
             *  Console.WriteLine("Test count: {0}, Run:{1}", testSet.Count, r);
             * }
             * catch (Exception e)
             * {
             *  Console.WriteLine("TestSet Error: {0}", e);
             * }
             *
             */
            Console.WriteLine("Press any key to close this window");
            Console.ReadKey();
        }
Пример #24
0
        } // end display_zero_results()

        /*****************************************************************************/
        /* display_results()                                                         */
        /*                                                                           */
        /* used to display the counts of errors, warnings and successes.  This may   */
        /* be called after a test against one MasterMind engine has been executed    */
        /*****************************************************************************/
        private void display_results(TestSet <IMMMaster> testset)
        {
            int num_failures = testset.TestSet_num_errors();
            int num_warnings = testset.TestSet_num_warnings();

            Failures.Text  = num_failures.ToString();
            Warnings.Text  = num_warnings.ToString();
            Successes.Text = (testset.TestSet_num_tests() - num_failures - num_warnings).ToString();
        } // end display_results()
Пример #25
0
        public void RunSet_CallbackCalledOnExpectedItems(TestSet set, int[] expected)
        {
            object           locker        = new object();
            int              expectedCount = expected.Length;
            AutoResetEvent   waiter        = new AutoResetEvent(false);
            List <int>       items         = new List <int>(3);
            TimerQueue <int> queue         = new TimerQueue <int>(v => {
                lock (locker)
                {
                    items.Add(v);
                    expectedCount--;
                    if (expectedCount == 0)
                    {
                        waiter.Set();
                    }
                }
            }, TimeSpan.FromMilliseconds(QueueDuration));

            foreach (TestEvent ev in set)
            {
                Thread.Sleep(TimeUnits * ev.Delay);

                switch (ev.Action)
                {
                case TestAction.Add:
                    queue.Add(ev.Item);
                    break;

                case TestAction.Remove:
                    queue.Remove(ev.Item);
                    break;

                case TestAction.Reset:
                    queue.Reset(ev.Item);
                    break;

                case TestAction.Clear:
                    queue.Clear();
                    break;

                case TestAction.Flush:
                    queue.Flush();
                    break;

                case TestAction.Count:
                    Assert.Equal(ev.Item, queue.Count);
                    break;
                }
            }

            waiter.WaitOne(QueueDuration * 4);

            string expectedStr = "[" + String.Join(",", expected.Select(x => x.ToString()).ToArray()) + "]";
            string actualStr   = "[" + String.Join(",", items.Select(x => x.ToString()).ToArray()) + "]";

            Assert.Equal(expectedStr, actualStr);
        }
Пример #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var testPage = new TestSet();

            // testPage.modelCs();
            testPage.test();
        }
Пример #27
0
 public void AddTestSet(TestSet testSet)
 {
     using (var session = SessionFactory.OpenSession())
         using (var transaction = session.BeginTransaction())
         {
             session.SaveOrUpdate(testSet);
             transaction.Commit();
         }
 }
Пример #28
0
        private void scaffoldWkEvidenceDirectory(string testCasePath, TestSet testSet)
        {
            var evidencePath = Path.Combine(testCasePath, "evidence");

            if (!Directory.Exists(evidencePath))
            {
                try
                {
                    Directory.CreateDirectory(evidencePath);
                }
                catch (IOException ioEx)
                {
                    var msg = string.Format(CLI_00102, evidencePath, ioEx);
                    throw new DoshScaffoldException(msg, ioEx);
                }
                catch (UnauthorizedAccessException anAuthEx)
                {
                    var msg = string.Format(CLI_00101, anAuthEx);
                    throw new DoshScaffoldException(msg, anAuthEx);
                }
                catch (System.Exception ex)
                {
                    var msg = string.Format(CLI_00100, ex);
                    throw new DoshScaffoldException(msg, ex);
                }
            }
            var stepCnt = 1;

            testSet.RunConfig.Steps.ForEach(r =>
            {
                var stepPath = Path.Combine(evidencePath, $"step{stepCnt}");
                if (!Directory.Exists(stepPath))
                {
                    try
                    {
                        Directory.CreateDirectory(stepPath);
                    }
                    catch (IOException ioEx)
                    {
                        var msg = string.Format(CLI_00102, stepPath, ioEx);
                        throw new DoshScaffoldException(msg, ioEx);
                    }
                    catch (UnauthorizedAccessException anAuthEx)
                    {
                        var msg = string.Format(CLI_00101, anAuthEx);
                        throw new DoshScaffoldException(msg, anAuthEx);
                    }
                    catch (System.Exception ex)
                    {
                        var msg = string.Format(CLI_00100, ex);
                        throw new DoshScaffoldException(msg, ex);
                    }
                }
                stepCnt++;
            });
        }
        private TestSet CountContainsTests()
        {
            var countContainsTrieTestSet = new TestSet(new Lab14_Trie(), "CountPrefix i Contains (0.5 pkt.)");

            countContainsTrieTestSet.TestCases.Add(new TrieTestCase(TIME_MULTIPLIER, null, "Test1 - counting added words",
                                                                    new List <ITrieOperation> {
                new AddTrieOp("Adding words",
                              new string[] { "asdf", "asdf", "abcd", "abc", "abcde" },
                              new bool[] { true, false, true, true, true }
                              ),
                new CountWordTrieOp("Count all", "", 4),
                new CountWordTrieOp("Count a*", "a", 4),
                new CountWordTrieOp("Count ab*", "ab", 3),
                new CountWordTrieOp("Count z*", "z", 0),
            }));

            countContainsTrieTestSet.TestCases.Add(new TrieTestCase(TIME_MULTIPLIER, null, "Test2 - counting added words",
                                                                    new List <ITrieOperation> {
                new AddTrieOp("Adding words",
                              new string[] { "abc", "xyz", "a", "w", "qwert", "abcd", "asdf", "qwerty" },
                              new bool[] { true, true, true, true, true, true, true, true }
                              ),
                new CountWordTrieOp("Count all", "", 8),
                new CountWordTrieOp("Count a*", "a", 4),
                new CountWordTrieOp("Count z*", "z", 0),
                new CountWordTrieOp("Count x*", "x", 1),
                new CountWordTrieOp("Count xx*", "xx", 0),
                new CountWordTrieOp("Count q*", "q", 2)
            }));

            countContainsTrieTestSet.TestCases.Add(new TrieTestCase(TIME_MULTIPLIER, null, "Test3 - contains check",
                                                                    new List <ITrieOperation> {
                new AddTrieOp("Adding words",
                              new string[] { "asdf", "asdf", "abcd", "abc", "abcde" },
                              new bool[] { true, false, true, true, true }
                              ),
                new CheckWordsTrieOp("Word checking",
                                     new string[] { "asdf", "xxx", "ab", "abcd", "abcdef", "abc", "abcde" },
                                     new bool[] { true, false, false, true, false, true, true }
                                     ),
            }));

            countContainsTrieTestSet.TestCases.Add(new TrieTestCase(TIME_MULTIPLIER, null, "Test4 - contains check",
                                                                    new List <ITrieOperation> {
                new AddTrieOp("Adding words",
                              new string[] { "abc", "xyz", "a", "w", "qwert", "abcd", "asdf", "qwerty" },
                              new bool[] { true, true, true, true, true, true, true, true }
                              ),
                new CheckWordsTrieOp("Word checking",
                                     new string[] { "asdf", "xxx", "ab", "abcd", "abcdef", "abc", "abcde", "w", "ww" },
                                     new bool[] { true, false, false, true, false, true, false, true, false }
                                     ),
            }));

            return(countContainsTrieTestSet);
        }
Пример #30
0
        private void CreateTestInstance(TestSet ts, List <string> TestID)
        {
            TSTestFactory tsF = ts.TSTestFactory as TSTestFactory;

            foreach (string id in TestID)
            {
                TSTest TestInstance = tsF.AddItem(id) as TSTest;
                TestInstance.Post();
            }
        }
Пример #31
0
        /// <summary>
        /// Gets the value of the specified symbol
        /// </summary>
        /// <param name="symbol">Symbol name</param>
        /// <returns>
        /// Null, if the symbol cannot be found; otherwise, the symbol's value
        /// </returns>
        public ExpressionValue GetSymbolValue(string symbol)
        {
            if (ParameterNames.Contains(symbol.ToUpperInvariant()))
            {
                // TODO: Update to get the real symbol value during run time
                return(ExpressionValue.NonEvaluated);
            }

            return(TestSet.GetSymbolValue(symbol));
        }
Пример #32
0
        public void TestExceptWith()
        {
            var set = new TestSet <int>
            {
                1, 2, 3, 4
            };

            set.ExceptWith(new[] { 3, 4, 5 });
            Assert.True(new[] { 1, 2 }.SequenceEqual(set));
        }
Пример #33
0
 public int  AddTest(int userId, int quizId)
 {
     var test = new TestSet
     {
         UserSet = _dbContext.UserSets.First(x => x.Id == userId),
         QuizSet = _dbContext.QuizSets.First(x => x.Id == quizId)
     };
     _dbContext.TestSets.Add(test);
     _dbContext.SaveChanges();
     return test.Id;
 }
Пример #34
0
        public void ConstructTestSetWithSequence()
        {
            // Setup
            var sequence = InitializeSequence();

            // Execute
            var set = new TestSet<TestEntity>(InitializeSequence());

            // Assert
            Assert.AreEqual(sequence.Length, set.Count);
        }
Пример #35
0
 /// <summary>
 /// Validate the object.
 /// </summary>
 /// <exception cref="ValidationException">
 /// Thrown if validation fails
 /// </exception>
 public virtual void Validate()
 {
     if (VersionNumber == null)
     {
         throw new ValidationException(ValidationRules.CannotBeNull, "VersionNumber");
     }
     if (TestSet != null)
     {
         TestSet.Validate();
     }
 }
Пример #36
0
        public void ContainsExistingEntity()
        {
            // Setup
            var sequence = InitializeSequence();
            var item = sequence[3];
            var set = new TestSet<TestEntity>(sequence);

            // Execute
            var result = set.Contains(item);

            // Assert
            Assert.IsTrue(result);
        }
Пример #37
0
        public void Clear()
        {
            // Setup
            var sequence = InitializeSequence();
            var set = new TestSet<TestEntity>(sequence);

            // Execute
            set.Clear();

            // Assert
            Assert.IsFalse(set.Any());
            Assert.AreEqual(0, set.Count);
        }
Пример #38
0
        public void AddEntity()
        {
            // Setup
            var item = InitializeSequence()[0];
            var set = new TestSet<TestEntity>();

            // Execute
            set.Add(item);

            // Assert
            Assert.AreEqual(1, set.Count);
            Assert.AreSame(item, set.First());
        }
        public void SpecSamplesTest(string template, string[] results, TestSet.TestCase testCase)
        {
            var uriTemplate = new UriTemplate(template);

            foreach (var variable in testCase.TestSet.Variables)
            {
                uriTemplate.SetParameter(variable.Key, variable.Value);
            }

            string result = null;
            result = uriTemplate.Resolve();

            Assert.True(results.Contains(result));
        }
Пример #40
0
 public void AddAndRunTest(TestSet ts,string caseid,string result)
 {
     var test = AddTestCase(ts,caseid);
     if(test!=null)
     {
         RunTest(test, result);
     }
 }
Пример #41
0
        private static TestSet.TestCase CreateTestCase(TestSet testSet, JToken testcase)
        {
            var testCase = new TestSet.TestCase(testSet);

            testCase.Template = testcase[0].Value<string>();

            if (testcase[1].Type == JTokenType.Array)
            {
                var results = (JArray)testcase[1];
                testCase.Result = results.Select(jv => jv.Value<string>()).ToArray();
            }
            else
            {
                testCase.Result = new string[1];
                testCase.Result[0] = testcase[1].Value<string>();
            }
            return testCase;
        }
Пример #42
0
 public TSTest AddTestCase(TestSet ts,string caseid)
 {
     TSTest result=null;
     try
     {
         var factory = ts.TSTestFactory as TSTestFactory;
         result = factory.AddItem(caseid) as TSTest;
     }
     catch (Exception e) { }
     return result;
 }
Пример #43
0
 public void ConstructTestWithNullSequence()
 {
     // Execute
     var set = new TestSet<TestEntity>(a_items: null);
 }
Пример #44
0
 public void RunTestSet(TestSet testSet)
 {
     TSScheduler scheduler = testSet.StartExecution("");
     scheduler.RunAllLocally = true;
     scheduler.Run();
 }
Пример #45
0
        public void RemoveNonexistingEntity()
        {
            // Setup
            var sequence = InitializeSequence();
            var removedItem = new SimpleType { Name = "NoExisty", Price = 0m, Value = 1000000 };
            var set = new TestSet<SimpleType>(sequence);

            // Execute
            var result = set.Remove(removedItem);

            // Assert
            Assert.IsFalse(result);
            Assert.AreEqual(sequence.Length, set.Count);
        }
Пример #46
0
        public void ContainsNonexistingEntity()
        {
            // Setup
            var sequence = InitializeSequence();
            var item = new SimpleType { Name = "ImNotReal", Price = 2.22m, Value = 2 };
            var set = new TestSet<SimpleType>(sequence);

            // Execute
            var result = set.Contains(item);

            // Assert
            Assert.IsFalse(result);
        }
Пример #47
0
        /**
         * set status for tests in a test set and update in QC
         *
         * @param TestSet testSet
         * @param Dictionary<string, string> testResults - testCaseName, testResult (e.g. "EHR_REF_PAT_0001", "Passed")
         */
        public void recordTestSetResults(TestSet testSet, Dictionary<string, string> testResults)
        {
            TestSetFolder tsFolder = (TestSetFolder)testSet.TestSetFolder;
            log.Debug("tsFolder.Path: " + tsFolder.Path);

            string testSetInfo = "testSet.ID: " + testSet.ID.ToString() + DELIM +
                                 "testSet.Name: " + testSet.Name + DELIM +
                                 "testSet.Status: " + testSet.Status + DELIM +
                                 "";

            log.Debug("testSetInfo: " + testSetInfo);

            TSTestFactory tsTestFactory = (TSTestFactory)testSet.TSTestFactory;
            List tsTestList = tsTestFactory.NewList("");

            foreach (TSTest tsTest in tsTestList)
            {
                testCount++;

                string testInfo = DELIM + DELIM + DELIM +
                                "TestId: " + tsTest.TestId + DELIM +
                                "TestName: " + tsTest.TestName + DELIM +
                                "";

                Run lastRun = (Run)tsTest.LastRun;
                if (lastRun != null)
                {
                    testInfo += lastRun.Name + DELIM + lastRun.Status;
                }

                log.Debug("TestInfo: " + testInfo);

                // look for a test in the results from this test set
                if (testResults.ContainsKey(tsTest.TestName))
                {
                    string status = testResults[tsTest.TestName];
                    recordTestResult(tsTest, status);
                }

            }
        }
Пример #48
0
        public void CopyTo()
        {
            // Setup
            var sequence = InitializeSequence();
            var set = new TestSet<SimpleType>(sequence);
            var array = new SimpleType[4];

            // Execute
            set.CopyTo(array, 0);

            // Assert
            Assert.IsTrue(array.All(i => i != null));
            Assert.AreSame(sequence[0], array[0]);
            Assert.AreSame(sequence[1], array[1]);
            Assert.AreSame(sequence[2], array[2]);
            Assert.AreSame(sequence[3], array[3]);
        }
 public MvTestFieldMapper(TestSet testSet, string name = "MvTest")
 {
     TestSet = testSet;
     Name = name;
 }
Пример #50
0
        public void CopyToAtNonZeroArrayIndex()
        {
            // Setup
            var sequence = InitializeSequence();
            var set = new TestSet<SimpleType>(sequence);
            var array = new SimpleType[5];

            // Execute
            set.CopyTo(array, 1);

            // Assert
            Assert.IsNull(array[0]);
            Assert.IsTrue(array.Skip(1).All(i => i != null));
            Assert.AreSame(sequence[0], array[1]);
            Assert.AreSame(sequence[1], array[2]);
            Assert.AreSame(sequence[2], array[3]);
            Assert.AreSame(sequence[3], array[4]);
        }
        public void Test(TestSet set)
        {
            var catagory = CategoryInstances[set.CategoryType];
            var expected = (ProjectionInfo)(set.CategoryType.GetField(set.FieldName).GetValue(catagory));

            ProjectionInfo actual;
            if (expected.Transform == null || expected.IsLatLon) {
                actual = Proj4CrsGeographic.CreateProjection(new Proj4CrsGeographic(expected.GeographicInfo));

                // NOTE: TEST HACK
                if (expected.Transform == null) {
                    actual.IsLatLon = false; // TODO: not sure why, but these are set to false for latlon on some CRSs
                    actual.Transform = null;
                }

            }
            else {
                actual = Proj4CrsProjected.CreateProjection(new Proj4CrsProjected(expected));
            }

            Assert.AreEqual(expected.alpha, actual.alpha);
            // TODO: authority
            Assert.AreEqual(expected.AuxiliarySphereType, actual.AuxiliarySphereType);
            Assert.AreEqual(expected.bns, actual.bns);
            Assert.AreEqual(expected.CentralMeridian, actual.CentralMeridian);
            Assert.AreEqual(expected.czech, actual.czech);
            Assert.AreEqual(expected.AuthorityCode, actual.AuthorityCode);
            Assert.AreEqual(expected.FalseEasting, actual.FalseEasting);
            Assert.AreEqual(expected.FalseNorthing, actual.FalseNorthing);
            Assert.AreEqual(expected.Geoc, actual.Geoc);
            // TODO: geographic info
            Assert.AreEqual(expected.guam, actual.guam);
            Assert.AreEqual(expected.h, actual.h);
            Assert.AreEqual(expected.IsGeocentric, actual.IsGeocentric);
            Assert.AreEqual(expected.IsLatLon, actual.IsLatLon);
            Assert.AreEqual(expected.IsSouth, actual.IsSouth);
            Assert.AreEqual(expected.IsValid, actual.IsValid);
            Assert.AreEqual(expected.lat_ts, actual.lat_ts);
            if(actual.LatitudeOfOrigin != 90 && actual.LatitudeOfOrigin != -90)
                Assert.AreEqual(expected.LatitudeOfOrigin, actual.LatitudeOfOrigin);
            Assert.AreEqual(expected.lon_1, actual.lon_1);
            Assert.AreEqual(expected.lon_2, actual.lon_2);
            Assert.AreEqual(expected.lonc, actual.lonc);
            Assert.AreEqual(expected.LongitudeOfCenter, actual.LongitudeOfCenter);
            Assert.AreEqual(expected.M, actual.M);
            Assert.AreEqual(expected.mGeneral, actual.mGeneral);
            Assert.AreEqual(expected.n, actual.n);
            //Assert.AreEqual(expected.Name, actual.Name);
            Assert.AreEqual(expected.no_rot, actual.no_rot);
            Assert.AreEqual(expected.no_uoff, actual.no_uoff);
            Assert.AreEqual(expected.NoDefs, actual.NoDefs);
            Assert.AreEqual(expected.Over, actual.Over);
            Assert.AreEqual(expected.rot_conv, actual.rot_conv);
            Assert.AreEqual(expected.ScaleFactor, actual.ScaleFactor);
            if(actual.StandardParallel1 != 90 && actual.StandardParallel1 != -90)
                Assert.AreEqual(expected.StandardParallel1, actual.StandardParallel1);
            Assert.AreEqual(expected.StandardParallel2, actual.StandardParallel2);
            Assert.AreEqual(expected.to_meter, actual.to_meter);
            // TODO: transform
            // TODO: unit
            Assert.AreEqual(expected.W, actual.W);
            Assert.AreEqual(expected.Zone, actual.Zone);

            // NOTE: TEST HACK
            // this projection may have a known ellipsoid of WGS84 but different parameters for it than Proj4Ellipsoid.WGS_1984
            if (IsFalseWgs84(expected.GeographicInfo.Datum.Spheroid))
                actual.GeographicInfo.Datum.Spheroid = new Spheroid(expected.GeographicInfo.Datum.Spheroid.KnownEllipsoid);

            // NOTE: TEST HACK
            if (IsInvalidSpheroid(expected.GeographicInfo.Datum.Spheroid))
                return; // this ellipsoid is all wrong

            //Assert.AreEqual(expected.ToProj4String(), actual.ToProj4String());
        }
Пример #52
0
        public void RemoveNull()
        {
            // Setup
            var sequence = InitializeSequence();
            var set = new TestSet<SimpleType>(sequence);

            // Execute
            var result = set.Remove(a_entity: null);

            // Assert
            Assert.IsFalse(result);
            Assert.AreEqual(sequence.Length, set.Count);
        }
Пример #53
0
        private static TestSet CreateTestSet(string name, JToken token)
        {
            var testSet = new TestSet();
            testSet.Name = name;

            var variables = token["variables"];

            foreach (JProperty variable in variables)
            {
                ParseVariable(variable, testSet.Variables);
            }

            var testcases = token["testcases"];

            foreach (var testcase in testcases)
            {
                testSet.TestCases.Add(CreateTestCase(testSet, testcase));
            }

            return testSet;
        }
        /*
          ////The filter can only filter the system fields
          //TDFilter TFilter = TestFact.Filter as TDFilter;
          ////All match item will be filtered by the provided field and value
          //foreach (TestConfigFile.AutorunFilerConfig filter in TConfig.CaseFilter.AutorunFilter)
          //{
          //  TFilter[filter.FieldName] = filter.FieldValue;
          //}
          //TFilter[TConfig.CaseFilter.TestSetName] = TSName;
          ////All matched test cases will be storaged in TList temporarily
          //List TList = TFilter.NewList();

          ////Add test set name
        */
        private void RunCurrentSet(TestSet RunSet, string destMachine, bool isQTPRun, string configpath)
        {
            Console.Out.WriteLine("Enter the RunCurrentSet");
              if (isQTPRun)
              {
            #region Using QTP
            Console.Out.WriteLine("==========[void RunCurrentSet]Now something exception happen for QTP scheduler");
            //Console.Out.WriteLine("AutoIntSys: Begin to load QTP");
            //TSTestFactory TSTestFact = RunSet.TSTestFactory as TSTestFactory;
            //List runList = new List();
            //runList = TSTestFact.NewList("") as List;
            //if (runList.Count < 1)
            //  return;
            //TSScheduler Scheduler = RunSet.StartExecution("localhost") as TSScheduler;
            //if (destMachine == "localhost")
            //  Scheduler.RunAllLocally = true;
            //else
            //  Scheduler.TdHostName = destMachine;

            //try
            //{
            //  Debug.Print("AutoIntSys: Run Start at: " + TestUtility.GetCurrentTime());
            //  Scheduler.Run(runList);
            //}
            //catch (Exception e)
            //{
            //  Debug.Print("AutoIntSys: RUNNING Test Case Error!");
            //  Debug.Print("AutoIntSys: " + e.Message);
            //}

            //ExecutionStatus execStatus = Scheduler.ExecutionStatus as ExecutionStatus;

            //bool isRunFinished = false;
            //while (!isRunFinished)
            //{
            //  execStatus.RefreshExecStatusInfo(runList, true);
            //  isRunFinished = execStatus.Finished;
            //  System.Threading.Thread.Sleep(5000);
            //}
            //Debug.Print("AutoIntSys: Run Finish at: " + TestUtility.GetCurrentTime());
            //Console.WriteLine("Run Finish at: {0}", TestUtility.GetCurrentTime());
            #endregion
              }
              else
              {
            CustomerProcess.CustomerProcess cp = new CustomerProcess.CustomerProcess();
            if (cp.LoadRunInstance(".") > 0)
            {
              AutoLog.Info("AutoIntSys: [void RunCurrentSet]Current Test set start run!");
              //Debug.Print("AutoIntSys: Run CP Start at: " + TestUtility.GetCurrentTime());
              //Console.Out.WriteLine("==========[void RunCurrentSet]Current Test set start: " + TestUtility.GetCurrentTime());
              AutoTestInterface.IRunTest runScheduler = cp.GetRunName(configFile.RunParameter.CustomerTestPro);
              runScheduler.Run(tdConn, RunSet, configpath);
              System.Threading.Thread.Sleep(5000);
              runScheduler.RunFinished();

              AutoLog.Info("AutoIntSys: [void RunCurrentSet]Current Test set end run!");
              //Debug.Print("AutoIntSys: Run CP Finish at: " + TestUtility.GetCurrentTime());
              //Console.Out.WriteLine("==========[void RunCurrentSet]Current Test set end: " + TestUtility.GetCurrentTime());
            }

            #region Unused
            /****

            // RunSet.ID
            // invoke the test execution
            TSTestFactory TSTestFact = RunSet.TSTestFactory as TSTestFactory;
            List runList = new List();
            runList = TSTestFact.NewList("") as List;
            foreach (TSTest instance in runList)
            {
              //generate the run first
              RunFactory runFact = instance.RunFactory as RunFactory;
              DateTime now = TestUtility.GetCurrentTime();
              Run instanceRun = runFact.AddItem("Run_" + now.ToShortDateString() +
                                          "_" + now.ToShortTimeString()) as Run;

              QCOperation.QCInformation info = new QCOperation.QCInformation();
              // string runID = instanceRun.ID as string;
              //Initial the start status
              info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Not Completed");
              //Add the run steps
              //info.SetTestRunStep(tdConn, runID, "Step 1", "Passed");
              //info.SetTestRunStep(tdConn, runID, "Step 2", "Failed");
              //Update the end status
              //info.SetTestRunStatus(tdConn, runID, "Failed");

              //Download test case attachments
              string caseID = instance.TestId as string;
              ArrayList attachments = new ArrayList();
              QCOperation.QCAttachment taa = new QCOperation.QCAttachment();
              foreach (string downfile in configFile.RunParameter.DownloadFile)
              {
            attachments.Add(taa.DownloadAttachment(tdConn, "TEST", caseID, downfile, "C:\\temp"));
              }

              //When finish the test, record the summary in instance of testset
              string instanceID = instance.ID as string;
              string scriptFilename = null;
              string dataFilename = null;
              for(int i = 0; i < attachments.Count; i++)
              {
            ArrayList downList = attachments[i] as ArrayList;
            if (downList.Count > 0)
            {
              foreach (Object fileObj in downList)
              {
                string tempFilePath = fileObj as string;
                if (tempFilePath != null && tempFilePath.EndsWith("cod"))
                {
                  scriptFilename = tempFilePath;
                }
                if (tempFilePath != null && tempFilePath.EndsWith("iod"))
                {
                  dataFilename = tempFilePath;
                }
              }
            }
              }
              if (scriptFilename != null)
                {
                  PAS.AutoTest.ScriptRunner.ScriptRunner sr = new PAS.AutoTest.ScriptRunner.ScriptRunner();
            PAS.AutoTest.ScriptRunner.ExecuteResult er;
            if (dataFilename!=null)
            {  er = sr.Run(scriptFilename, dataFilename, 600); }
            else
            {  er = sr.Run(scriptFilename, string.Empty, 600); }
                  switch (er.Output.Result)
                  {
                    case PAS.AutoTest.TestData.TestResult.Pass:
                      info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Passed");
                      break;
                    case PAS.AutoTest.TestData.TestResult.Fail:
                      info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Failed");
                      break;
                    default:
                      info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Not Completed");
                      break;
                  }

                  info.SetTestInstanceSummary(tdConn, instanceID, configFile.RunParameter.NumOfPassed, er.Output.Summary.Passed.ToString());
                  info.SetTestInstanceSummary(tdConn, instanceID, configFile.RunParameter.NumOfTotal, er.Output.Summary.TotalRun.ToString());
                }
            }
             ****/
            #endregion

              }
        }
Пример #55
0
 public TestCase(TestSet testSet)
 {
     _testSet = testSet;
 }
Пример #56
0
 public IEnumerable<TSTest> GetTestFromTestSet(TestSet ts)
 {
     TSTestFactory tsFactory = ts.TSTestFactory as TSTestFactory;
     var testList = tsFactory.NewList("") as List;
     foreach(TSTest test in testList)
     {
         yield return test;
     }
 }
Пример #57
0
    // Run a series of tests with different table and collection styles.
    bool RunTest()
    {
        // Number of nodes we'll allocate in each run (we could take this as an argument instead).
        int numNodes = 10000;

        // Run everything under an exception handler since test errors are reported as exceptions.
        try
        {
            // Run a pass with each table style. For each style run through the collection styles in the order
            // None, Alternate, Random and All. This sequence is carefully selected to remove progressively
            // more nodes from the array (since, within a given TestSet instance, once a node has actually
            // been collected it won't be resurrected for future runs).

            TestSet ts1 = new TestSet(TableStyle.Unconnected, numNodes);
            ts1.Run(CollectStyle.None);
            ts1.Run(CollectStyle.Alternate);
            ts1.Run(CollectStyle.Random);
            ts1.Run(CollectStyle.All);

            TestSet ts2 = new TestSet(TableStyle.ForwardLinked, numNodes);
            ts2.Run(CollectStyle.None);
            ts2.Run(CollectStyle.Alternate);
            ts2.Run(CollectStyle.Random);
            ts2.Run(CollectStyle.All);

            TestSet ts3 = new TestSet(TableStyle.BackwardLinked, numNodes);
            ts3.Run(CollectStyle.None);
            ts3.Run(CollectStyle.Alternate);
            ts3.Run(CollectStyle.Random);
            ts3.Run(CollectStyle.All);

            TestSet ts4 = new TestSet(TableStyle.Random, numNodes);
            ts4.Run(CollectStyle.None);
            ts4.Run(CollectStyle.Alternate);
            ts4.Run(CollectStyle.Random);
            ts4.Run(CollectStyle.All);
        }
        catch (TestException te)
        {
            // "Expected" errors.
            Console.WriteLine("TestError: {0}", te.Message);
            return false;
        }
        catch (Exception e)
        {
            // Totally unexpected errors (probably shouldn't see these unless there's a test bug).
            Console.WriteLine("Unexpected exception: {0}", e.GetType().Name);
            return false;
        }

        // If we get as far as here the test succeeded.
        return true;
    }
        public bool Run(TDConnectionClass tdConn, TestSet RunSet, string configPath)
        {
            try
              {
              //Console.WriteLine("Test run from Interface of IRunTest!");
              Debug.Print("PAS: Test run from Interface of IRunTest!");
              TestConfigFile tConfig = new TestConfigFile();
              TestUtility.LoadConfigFile(ref tConfig, configPath);

              // invoke the test execution
              TSTestFactory TSTestFact = RunSet.TSTestFactory as TSTestFactory;
              List runList = new List();
              runList = TSTestFact.NewList("") as List;
              foreach (TSTest instance in runList)
              {
            //generate the run first
            RunFactory runFact = instance.RunFactory as RunFactory;
            DateTime now = DateTime.Now;
            Run instanceRun = runFact.AddItem("Run_" + now.ToShortDateString() +
                                        "_" + now.ToShortTimeString()) as Run;

            QCOperation.QCInformation info = new QCOperation.QCInformation();
            // string runID = instanceRun.ID as string;
            //Initial the start status
            info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Not Completed");
            //Add the run steps
            //info.SetTestRunStep(tdConn, runID, "Step 1", "Passed");
            //info.SetTestRunStep(tdConn, runID, "Step 2", "Failed");
            //Update the end status
            //info.SetTestRunStatus(tdConn, runID, "Failed");

            //Download test case attachments
            string caseID = instance.TestId as string;
            ArrayList attachments = new ArrayList();
            QCOperation.QCAttachment taa = new QCOperation.QCAttachment();
            foreach (string downfile in tConfig.RunParameter.DownloadFile)
            {
              attachments.Add(taa.DownloadAttachment(tdConn, "TEST", caseID, downfile, @"C:\CSAutoTest\Temp"));
            }

            //When finish the test, record the summary in instance of testset
            string instanceID = instance.ID as string;
            string scriptFilename = null;
            string dataFilename = null;
            for (int i = 0; i < attachments.Count; i++)
            {
              ArrayList downList = attachments[i] as ArrayList;
              if (downList.Count > 0)
              {
            foreach (Object fileObj in downList)
            {
              string tempFilePath = fileObj as string;
              if (tempFilePath != null && tempFilePath.EndsWith("cod"))
              {
                scriptFilename = tempFilePath;
              }
              if (tempFilePath != null && tempFilePath.EndsWith("iod"))
              {
                dataFilename = tempFilePath;
              }
            }
              }
            }
            if (scriptFilename != null)
            {
              PAS.AutoTest.ScriptRunner.ScriptRunner sr = new PAS.AutoTest.ScriptRunner.ScriptRunner();
              PAS.AutoTest.ScriptRunner.ExecuteResult er;
            Debug.Print("PAS: Script file name: {0}", scriptFilename);
            Debug.Print("PAS: Data file name: {0}", dataFilename);
              if (dataFilename != null)
            { er = sr.Run(scriptFilename, dataFilename, 1200); }
              else
            { er = sr.Run(scriptFilename, string.Empty, 1200); }
            switch (er.Result)
              {
              case PAS.AutoTest.TestData.TestResult.Done:
                info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Passed");
                break;
            case PAS.AutoTest.TestData.TestResult.Pass:
              info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Passed");
              break;
            case PAS.AutoTest.TestData.TestResult.Fail:
              info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Failed");
              break;
              case PAS.AutoTest.TestData.TestResult.Incomplete:
              info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "Not Completed");
              break;
                //default:
              case PAS.AutoTest.TestData.TestResult.Warning:
                info.SetTestRunStatus(tdConn, instanceRun.ID.ToString(), "N/A");
                break;

              }
            if (er.Result != PAS.AutoTest.TestData.TestResult.Incomplete)
            {
              info.SetTestInstanceSummary(tdConn, instanceID, tConfig.RunParameter.NumOfPassed, er.Output.Summary.Passed.ToString());
              info.SetTestInstanceSummary(tdConn, instanceID, tConfig.RunParameter.NumOfTotal, er.Output.Summary.TotalRun.ToString());

              string fileLog = ".log";
              fileLog = "TEST_" + caseID + "_" + now.ToShortDateString() + "_" + now.ToShortTimeString() + ".log";
              fileLog = ConvertChar(fileLog);
              er.Output.ConvertToXml(".\\Temp\\" + fileLog);
              bool uploadSuccess = false;
              uploadSuccess = taa.UploadAttachment(tdConn, "RUN", instanceRun.ID.ToString(), fileLog, GetCurrentRunDir() + "\\Temp\\");
              if (uploadSuccess)
              {
            Debug.Print("PAS: Upload test log sucess!");
              }
              else
              {
            Debug.Print("PAS: Upload test log fail!");
              }
            }
              }
            }
              }
              catch
              {
            Debug.Print("PAS: Run test case error!");
              }

              return true;
        }
Пример #59
0
 // Allocate a node and remember our owner (TestSet) and ID (index into node array).
 public Node(TestSet owner, int id)
 {
     m_owner = owner;
     m_id = id;
 }
Пример #60
0
        public void RemoveEntity()
        {
            // Setup
            var sequence = InitializeSequence();
            var removedItem = sequence[1];
            var set = new TestSet<SimpleType>(sequence);

            // Execute
            var result = set.Remove(removedItem);

            // Assert
            Assert.IsTrue(result);
            Assert.AreEqual(sequence.Length - 1, set.Count);
        }