示例#1
0
        public void DisplayNotification(TestResults results)
        {
            Notification notification;

            if (IsSuccess(results))
            {
                notification = new Notification(ApplicationName, Success, "1", "Pass", BuildSuccessDisplayText(results))
                                   {
                                       Priority = Priority.Normal
                                   };
            }
            else if(IsFail(results))
            {
                notification = new Notification(ApplicationName, Failed, "2", "Fail", BuildFailDisplayText(results))
                                   {
                                       Priority = Priority.High
                                   };
            }
            else
            {
                notification = new Notification(ApplicationName, Inconclusive, "3", "Inconclusive", BuildInconclusiveDisplayText(results))
                                   {
                                       Priority = Priority.VeryLow
                                   };
            }

            _growl.Notify(notification);
        }
        public void ReportTests(TestResults results)
        {
            if (results != null)
            {
                var tests = results.GetTests().ToList();
                // unfortunately we cant capture names or details of "non failed" tests at present, so need to generate names for all non failed tests!                
                foreach (var test in tests)
                {
                    if (test.Kind == TestResultKind.Skipped)
                    {
                        ReportTestIgnored(test);
                        continue;
                    }

                    ReportTestStarted(test);

                    if (test.Kind == TestResultKind.Failure)
                    {
                        ReportTestFailed(test);
                    }

                    ReportTestFinished(test);
                    testCounter = testCounter + 1;
                }
            }
        }
        public void ReportTests(TestResults results)
        {
            if (results != null)
            {
                var tests = results.GetTests().ToList();
                var passedTests = tests.Where(t => t.Kind == TestResultKind.Passed).ToList();
                var skippedTests = tests.Where(t => t.Kind == TestResultKind.Skipped).ToList();
                var inconclusiveTests = tests.Where(t => t.Kind == TestResultKind.Inconclusive).ToList();
                var failedTests = tests.Where(t => t.Kind == TestResultKind.Failure).ToList();

                _Writer(string.Format("Tests Summary", passedTests.Count));
                _Writer("---------------------");
                _Writer(string.Format("          Passed: {0}", passedTests.Count));
                _Writer(string.Format("         Skipped: {0}", skippedTests.Count));
                _Writer(string.Format("    Inconclusive: {0}", inconclusiveTests.Count));
                _Writer(string.Format("          Failed: {0}", failedTests.Count));

                if (failedTests.Any())
                {
                    _Writer(string.Format("Failed Tests", passedTests.Count));                  
                    foreach (var failedTest in failedTests)
                    {
                        _Writer("-----------------------------------------------");
                        _Writer(string.Format(" Name: {0}", failedTest.Name));
                        _Writer(string.Format(" Message: {0}", failedTest.Message));
                        _Writer(string.Format(" Output: {0}", failedTest.StackTrace));
                        _Writer("-----------------------------------------------");
                    }
                }               
            }
            // DO NOTHING.
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     var context = HttpUtility.Wrap(this.Context);
     using (var tc_output = new MemoryStream())
     using (var tc_writer = new StreamWriter(tc_output))
     using (var renderer_output = new MemoryStream())
     using (var renderer_writer = new StreamWriter(renderer_output))
     {
         result = Runner.Run(new HostedOptions
         {
             InputFiles = Path.Combine(Path.Combine(context.Request.MapPath("/"), "bin"), "TestsInWebContext.dll"),
             WorkDirectory = this.GetType().Assembly.Location,
         }, new Messages.OnMessage[] {
             new TeamCityMessageWriter(tc_writer).OnMessage,
             new NUnitRenderer(context, renderer_writer).OnMessage,
             //new AppendMessagesToFile("C:\\src\\messages.json")
         });
         tc_writer.Flush();
         tc_output.Seek(0, SeekOrigin.Begin);
         ConsoleOut = result.Message + Environment.NewLine
             + new StreamReader(tc_output).ReadToEnd();
         renderer_writer.Flush();
         renderer_output.Seek(0, SeekOrigin.Begin);
         RenderedResults = new StreamReader(renderer_output).ReadToEnd();
     }
     HeaderTitle = "TestsInWebContext";
 }
        public TestResults RunPerformanceTest()
        {
            Console.WriteLine("Running performance test '{0}'", Name);
            TestResults results = new TestResults(Name);

            foreach (RunMethod run in runMethods)
            {
                Console.WriteLine("Running for {0}", run.Method.Name);
                double totalRunTime = 0.0d;

                for (int i = 0; i < 10; i++)
                {
                    Console.Write(" | ");

                    TimeSpan start = Process.GetCurrentProcess().TotalProcessorTime;

                    for (int j = 0; j < Iterations; j++)
                    {
                        run(GenerateList());
                    }

                    TimeSpan end = Process.GetCurrentProcess().TotalProcessorTime;
                    double time = (end - start).TotalMilliseconds;

                    Console.Write(time);
                    totalRunTime += time;
                }

                Console.WriteLine("\nAverage time for {0} executions: {1}", Iterations, totalRunTime / 10);
                results.AddResult(run.Method.Name, totalRunTime / 10);
            }

            return results;
        }
 public TestOutputParser(IAndroidDebugBridgeFactory adbFactory, Device device)
 {
     _adbFactory = adbFactory;
     _device = device;
     _TestResults = new TestResults();
     _TestReportTestResults = new TestResults();
     _bundleResultParsers = LoadParsers();
     //_testSuiteFailedTests = new List<TestResult>();
 }
示例#7
0
        public static TestResults Test(int threadCount, int itemsCount, Action<int> testFunction)
        {
            List<TestResults> results = new List<TestResults>();
            for (int i = 0; i < threadCount; i++)
                results.Add(new TestResults());

            List<Thread> threads = new List<Thread>();
            int batchsize = itemsCount / threadCount;

            for (int i = 0; i < threadCount; i++)
            {
                var thread = new Thread(new ParameterizedThreadStart(delegate(object obj)
                    {
                        int threadnumber = (int)obj;

                        int batchstart = (batchsize * threadnumber);
                        Stopwatch sw = new Stopwatch();
                        try
                        {
                            sw.Start();

                            for (int itemnumber = 0; itemnumber < batchsize; itemnumber++)
                                testFunction(itemnumber + batchstart);

                            sw.Stop();
                        }
                        catch (Exception ex)
                        {
                            results[threadnumber].Exception = ex;
                        }

                        results[threadnumber].ElapsedMilliseconds = sw.ElapsedMilliseconds;
                        results[threadnumber].ThreadNumber = threadnumber;

                    }));
                threads.Add(thread);
            }
            for (int i = 0; i < threadCount; i++)
                threads[i].Start(i);

            for (int i = 0; i < threadCount; i++)
                threads[i].Join();

            TestResults tr = new TestResults();
            for (int i = 0; i < threadCount; i++)
            {
                tr.ElapsedMilliseconds += results[i].ElapsedMilliseconds;

                if (results[i].Exception != null)
                    tr.Exception = results[i].Exception;
            }
            tr.ThreadNumber = threadCount;

            return tr;
        }
        public TestResultModel LoadFrom(TestResults results)
        {
            this.Duration = TimeSpan.FromSeconds(results.Duration);
            this.FailCount = results.FailCount;
            this.PassCount = results.PassCount;
            this.SkipCount = results.SkipCount;            

            this.Suites = results.Suites.Select(x => new TestSuiteModel().LoadFrom(x)).ToList();

            return this;
        }
示例#9
0
        private void OnAllTestsCompleted(object sender, EventArgs<TestResults> e)
        {
            _testRunner.AllTestsCompleted -= OnAllTestsCompleted;

            _testResults = (TestResults)e.Item;
            foreach(string key in _testResults.Keys) {
                _resultPanel.Sections.Add(new ListSection(key, _testResults[key].Count));
            }

            _testSummary.SetTestResults(_testResults);
        }
        public void Can_Union_Test_Results()
        {
            var resultSetOne = new TestResults();
            var testA = new TestResult("My Special Test A", TestResultKind.Passed);            
            resultSetOne.AddTest(testA);

            var testB = new TestResult("My Special Test B", TestResultKind.Failure);
            testB.StackTrace = "Special stack trace";
            resultSetOne.AddTest(testB);

            var testC = new TestResult("My Special Test C", TestResultKind.Skipped);         
            resultSetOne.AddTest(testC);
            
            var resultSetTwo = new TestResults();
            var dummyTestA = new TestResult("", TestResultKind.Passed);           
            resultSetTwo.AddTest(dummyTestA);

            var dummyTestB = new TestResult("My Special Test B", TestResultKind.Failure);            
            resultSetTwo.AddTest(dummyTestB);

            var dummyTestC = new TestResult("", TestResultKind.Inconclusive);          
            resultSetTwo.AddTest(dummyTestC);

            resultSetOne.Merge(resultSetTwo);

            Assert.That(resultSetOne != null);
            var tests = resultSetOne.GetTests().ToList();


            Assert.That(tests.Count == 4);

            var firstTest = tests[0];
            Assert.That(firstTest.Name == testA.Name);
            Assert.That(firstTest.Kind == testA.Kind);

            var secondTest = tests[1];
            Assert.That(secondTest.Name == testB.Name);
            Assert.That(secondTest.Kind == testB.Kind);
            Assert.That(secondTest.StackTrace == testB.StackTrace);

            var thirdTest = tests[2];
            Assert.That(thirdTest.Name == testC.Name);
            Assert.That(thirdTest.Kind == testC.Kind);

            var fourthTest = tests[3];
            Assert.That(fourthTest.Name == dummyTestC.Name);
            Assert.That(fourthTest.Kind == dummyTestC.Kind);

        }      
示例#11
0
        protected override TestResults GetResults(string testFixtureName)
        {
            Trace.Assert(!String.IsNullOrWhiteSpace(testFixtureName));

              TestResults res = new TestResults(testFixtureName);
              foreach (KeyValuePair<string, object> testResult in (IDictionary<string, object>) js.GetGlobal("results"))
              {
            if (testResult.Value == null)
            {
              res.AddPassedTest(testResult.Key);
            } else
            {
              res.AddFailedTest(testResult.Key);
            }
              }
              return res;
        }
示例#12
0
        public void Test(Int32 ProblemID, Int32 SolutionID, string SolutionName, 
            ProgrammingLanguages PL, TournamentFormats TF, ProblemTypes PT,
            out TestResults Result, out int Score, out List<Tuple<long, long, TestResults>> testResults)
        {
            CanTest.Wait();
            AllDone.Reset();
            Interlocked.Increment(ref threadCount);

            logger.Debug("Start {0} thread", threadCount);
            if (logger.IsDebugEnabled)
                Console.WriteLine(DateTime.Now.ToString(culture) + " - Start {0} thread", threadCount);

            // TODO: FL
            Result = TestResults.RTE;
            Score = 0;
            testResults = null;

            logger.Trace("Start testing solution {0}", SolutionID);
            if (logger.IsTraceEnabled)
                Console.WriteLine(DateTime.Now.ToString(culture) + " - Start testing solution {0}", SolutionID);

            try
            {
                switch (PT)
                {
                    case ProblemTypes.Standart:
                        TestStandart(ProblemID, SolutionID, SolutionName, PL, TF, out Result, out Score, out testResults);
                        break;
                    case ProblemTypes.Open:
                        TestOpen(ProblemID, SolutionID, SolutionName, PL, TF, out Result, out Score);
                        break;

                }

            }
            catch (Exception ex)
            {
                logger.Error("Error occurred on solution {0} testing: {1}", SolutionID, ex.Message);
                Console.WriteLine(DateTime.Now.ToString(culture) + " - Error occurred on solution {0} testing: {1}", SolutionID, ex.Message);
            }

            Interlocked.Decrement(ref threadCount);
            if (threadCount == 0)
                AllDone.Set();
        }
示例#13
0
        public void TestNotUndoableField()
        {
            TestResults.Reinitialise();

            Csla.Test.DataBinding.ParentEntity p = CreateParentEntityInstance();

            p.NotUndoable = "something";
            p.Data        = "data";
            p.BeginEdit();
            p.NotUndoable = "something else";
            p.Data        = "new data";
            p.CancelEdit();
            //NotUndoable property points to a private field marked with [NotUndoable()]
            //so its state is never copied when BeginEdit() is called
            Assert.AreEqual("something else", p.NotUndoable);
            //the Data property points to a field that is undoable, so it reverts
            Assert.AreEqual("data", p.Data);
        }
示例#14
0
        private async Task RunOnce()
        {
            TestResult testResult = null;

            if (!string.IsNullOrEmpty(DownloadUrl) && IsDownloadUrlValid)
            {
                testResult = await internetService.Get(downloadUri);

                LastResult = testResult;

                TestResults.Add(testResult);
            }

            if (!string.IsNullOrEmpty(ResultsUrl) && IsResultsUrlValid)
            {
                var resultsPostResponse = await internetService.PostResult(resultsUri, testResult, hostName);
            }
        }
        public void TestBasicDispatch()
        {
            var testResults = new TestResults();
            var countTaker  = World.ActorFor <ICountTaker>(
                Definition.Has <CountTakerActor>(
                    Definition.Parameters(testResults), "testRingMailbox", "countTaker-1"));
            const int totalCount = MailboxSize / 2;

            testResults.Until = Until(MaxCount);

            for (var count = 1; count <= totalCount; ++count)
            {
                countTaker.Take(count);
            }
            testResults.Until.Completes();

            Assert.Equal(MaxCount, testResults.Highest.Get());
        }
示例#16
0
        private void ProcessPartialXmlTestCase(string testcase)
        {
            // Do nothing in case timeout occured
            if (TimedOut)
            {
                return;
            }

            // Try to extract name testcase
            if (_rgxTestCaseName.IsMatch(testcase))
            {
                var mr     = _rgxTestCaseName.Match(testcase);
                var name   = mr.Groups[1].Value;
                var result = new TestResult(testcase, name, _settings, true, false);

                TestResults.Add(result);
            }
        }
示例#17
0
        public void UpdateWithIntercept()
        {
            TestResults.Reinitialise();

            var obj = GetInitializeRoot("abc");

            TestResults.Reinitialise();

            obj.Name = "xyz";
            obj      = obj.Save();

            Assert.AreEqual("Initialize", TestResults.GetResult("Intercept1+InitializeRoot"), "Initialize should have run");
            Assert.AreEqual("Update", TestResults.GetResult("InterceptOp1+InitializeRoot"), "Initialize op should be Update");
            Assert.AreEqual("Complete", TestResults.GetResult("Intercept2+InitializeRoot"), "Complete should have run");
            Assert.AreEqual("Update", TestResults.GetResult("InterceptOp2+InitializeRoot"), "Complete op should be Update");
            Assert.IsFalse(TestResults.ContainsResult("Activate1+InitializeRoot"), "CreateInstance should not have run");
            Assert.AreEqual("InitializeInstance", TestResults.GetResult("Activate2+InitializeRoot"), "InitializeInstance should have run");
        }
示例#18
0
        public void TestNameValueList()
        {
            TestResults.Reinitialise();

            NameValueListObj nvList = GetNameValueListObjInstance();

            Assert.AreEqual("Fetched", TestResults.GetResult("NameValueListObj"));

            Assert.AreEqual("element_1", nvList[1].Value);

            //won't work, because IsReadOnly is set to true after object is populated in the for
            //loop in DataPortal_Fetch
            //NameValueListObj.NameValuePair newPair = new NameValueListObj.NameValuePair(45, "something");

            //nvList.Add(newPair);

            //Assert.AreEqual("something", nvList[45].Value);
        }
        private async Task AccessGeolocation()
        {
            try
            {
                var request  = new GeolocationRequest(GeolocationAccuracy.Best);
                var location = await Geolocation.GetLocationAsync(request);

                Stopwatchy.Stop();
                if (location != null)
                {
                    TestResults.Add(new TestResult(Stopwatchy.Elapsed.TotalMilliseconds * 1000000, $"Latitude: {location.Latitude}, Longitude: {location.Longitude}, Altitude: {location.Altitude}"));
                    if (--NumberOfIterationsLeft > 0)
                    {
                        Test();
                    }
                    else
                    {
                        var durationSum = 0.0;
                        foreach (var testResult in TestResults)
                        {
                            durationSum += testResult.Duration;
                        }
                        var durationAvg = durationSum / TestResults.Count;
                        TestResults.Add(new TestResult(durationAvg, "(AVERAGE) ALL TESTS FINISHED"));
                    }
                }
            }
            catch (FeatureNotSupportedException fnsEx)
            {
                // Handle not supported on device exception
            }
            catch (FeatureNotEnabledException fneEx)
            {
                // Handle not enabled on device exception
            }
            catch (PermissionException pEx)
            {
                // Handle permission exception
            }
            catch (Exception ex)
            {
                // Unable to get location
            }
        }
示例#20
0
        private void BurstSerials(List <string> theSerials)
        {
//#if 1
            if (inProcessRB.Checked)
            {
                PMDatabases.UpdateDatabases burstData = new PMDatabases.UpdateDatabases();

                string sWorkCode = GetWorkCode();

                // ja - this will read the partnumber from epicor
                TestResults res = new TestResults(sWorkCode);

                string sPartNumber = res.GetPartNumber();

                int nArraySize = theSerials.Count;

                string[] serialNumbers = new string[nArraySize];

                int nPosition = 0;
                foreach (string sSerial in theSerials)
                {
                    serialNumbers[nPosition] = sSerial;

                    nPosition++;
                }

                try
                {
                    if (!burstData.Burst(serialNumbers, sPartNumber, sWorkCode))
                    {
                        TestResults.LogLables(theSerials, false, "InProcess", "", true);
                        MessageBox.Show("Error Bursting labels, please try again!");
                    }

                    LogLables(theSerials);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }

//#endif
        }
示例#21
0
        public IActionResult SaveChanges(int score)
        {
            string userId = GetUserId();

            if (userId != null)
            {
                int testId     = _helper.GetLastTestId();
                int categoryId = _helper.GetLastSubcategoryId();
                int langId     = Helper.GetLanguagesId().Item2;

                using (_db)
                {
                    TestResults oldResults;
                    bool        isDone = _helper.IsTestDoneOnce(userId, testId, langId, categoryId, out oldResults);
                    if (isDone)
                    {
                        int oldScore = oldResults.Result;
                        if (score > oldScore)
                        {
                            oldResults.Result           = score;
                            oldResults.TestDate         = DateTime.Now;
                            _db.Entry(oldResults).State = EntityState.Modified;
                        }
                    }
                    else
                    {
                        TestResults results = new TestResults
                        {
                            TestId     = testId,
                            Result     = score,
                            UserId     = userId,
                            CategoryId = categoryId,
                            LangId     = langId,
                            TestDate   = DateTime.Now
                        };
                        _db.TestResults.Add(results);
                    }
                    _db.SaveChanges();

                    _helper.UpdateTotalScore(userId, langId);
                }
            }
            return(RedirectToAction("Index"));
        }
示例#22
0
        private void Form1_Load(object sender, EventArgs e)
        {
#if DEBUG
            //workcodeTB.Text = "70706";
            workcodeTB.Text = "67219";
#else
            // ja - temp
            //finalCheckBox.Checked = true;
            //finalCheckBox.Enabled = false;
#endif
            // ja - init to make faster later on
            TheTestResults = new TestResults();

            DisableAllControls();

            sHardcodedLabel = ReadConfigFile("hardcoded");
            sDataLabel      = ReadConfigFile("data");
            BurstLabels     = false;
        }
示例#23
0
        public void SetupQueryMessageToRepo(Message msgToRepoQuery, TestResults tr, string FileConnectAddress, string MessageConnectAddress, string loadType)
        {
            XElement fileMessage    = new XElement("FileMessage");
            XElement connectMessage = new XElement("ConnectMessage");

            connectMessage.Add(new XElement("FileConnectAddress", FileConnectAddress));
            connectMessage.Add(new XElement("MessageConnectAddress", MessageConnectAddress));

            fileMessage.Add(new XElement("LoadType", "Upload"));
            fileMessage.Add(new XElement("LoadPath", Path.Combine(Directory.GetCurrentDirectory(), "..\\..\\..\\TestResults")));
            XElement filenames = new XElement("FileNames", new XElement("File", tr.LogName + "Summary.txt"));

            fileMessage.Add(filenames);
            msgToRepoQuery.fileMessage.xmlLoadMessage = fileMessage.ToString();
            msgToRepoQuery.sender                     = "Client";
            msgToRepoQuery.recipient                  = "Query";
            msgToRepoQuery.xmlConnectMessage          = connectMessage.ToString();
            msgToRepoQuery.fileMessage.xmlLoadMessage = fileMessage.ToString();
        }
示例#24
0
        protected override TestResults GetResults(string testFixtureName)
        {
            Trace.Assert(!String.IsNullOrWhiteSpace(testFixtureName));

            TestResults res = new TestResults(testFixtureName);

            foreach (KeyValuePair <string, object> testResult in (IDictionary <string, object>)js.GetGlobal("results"))
            {
                if (testResult.Value == null)
                {
                    res.AddPassedTest(testResult.Key);
                }
                else
                {
                    res.AddFailedTest(testResult.Key);
                }
            }
            return(res);
        }
示例#25
0
        public void FailUpdateContext()
        {
            TestDIContext testDIContext            = TestDIContextFactory.CreateContext(opts => opts.DataPortal(cfg => cfg.DataPortalReturnObjectOnException(true)));
            IDataPortal <ExceptionRoot> dataPortal = testDIContext.CreateDataPortal <ExceptionRoot>();

            try
            {
                TestResults.Reinitialise();

                ExceptionRoot root;
                try
                {
                    root = dataPortal.Create(new ExceptionRoot.Criteria());
                    Assert.Fail("Create exception didn't occur");
                }
                catch (DataPortalException ex)
                {
                    root = (ExceptionRoot)ex.BusinessObject;
                    Assert.AreEqual("Fail create", ex.GetBaseException().Message, "Base exception message incorrect");
                    Assert.IsTrue(ex.Message.StartsWith("DataPortal.Create failed"), "Exception message incorrect");
                }

                root.Data = "boom";
                try
                {
                    root = root.Save();

                    Assert.Fail("Insert exception didn't occur");
                }
                catch (DataPortalException ex)
                {
                    root = (ExceptionRoot)ex.BusinessObject;
                    Assert.AreEqual("Fail insert", ex.GetBaseException().Message, "Base exception message incorrect");
                    Assert.IsTrue(ex.Message.StartsWith("DataPortal.Update failed"), "Exception message incorrect");
                }

                Assert.AreEqual("boom", root.Data, "Business object not returned");
                Assert.AreEqual("create", TestResults.GetResult("create"), "GlobalContext not preserved");
            }
            finally
            {
            }
        }
示例#26
0
        public void TestBasicDispatch()
        {
            var testResult = new TestResults(MailboxSize);
            var dispatcher = new ManyToOneConcurrentArrayQueueDispatcher(MailboxSize, 2, false, 4, 10);

            dispatcher.Start();
            var mailbox = dispatcher.Mailbox;
            var actor   = new CountTakerActor(testResult);

            for (var count = 1; count <= MailboxSize; ++count)
            {
                var countParam = count;
                Action <ICountTaker> consumer = consumerActor => consumerActor.Take(countParam);
                var message = new LocalMessage <ICountTaker>(actor, consumer, "Take(int)");
                mailbox.Send(message);
            }

            Assert.Equal(MailboxSize, testResult.GetHighest());
        }
示例#27
0
        public void ExecuteCommandWithIntercept()
        {
            IDataPortal <InterceptorCommand> dataPortal = _testDIContext.CreateDataPortal <InterceptorCommand>();

            TestResults.Reinitialise();

            var obj = dataPortal.Create();

            TestResults.Reinitialise();
            obj = dataPortal.Execute(obj);

            Assert.AreEqual("Execute", TestResults.GetResult("InterceptorCommand"), "Execute should have run");
            Assert.AreEqual("Initialize", TestResults.GetResult("Intercept1+InterceptorCommand"), "Initialize should have run");
            Assert.AreEqual("Execute", TestResults.GetResult("InterceptOp1+InterceptorCommand"), "Initialize op should be Execute");
            Assert.AreEqual("Complete", TestResults.GetResult("Intercept2+InterceptorCommand"), "Complete should have run");
            Assert.AreEqual("Execute", TestResults.GetResult("InterceptOp2+InterceptorCommand"), "Complete op should be Execute");
            Assert.IsFalse(TestResults.ContainsResult("Activate1+InterceptorCommand"), "CreateInstance should not have run");
            Assert.AreEqual("InitializeInstance", TestResults.GetResult("Activate2+InterceptorCommand"), "InitializeInstance should have run");
        }
示例#28
0
        public void InvalidAsyncRule()
        {
            IDataPortal <HasInvalidAsyncRule> dataPortal = _testDIContext.CreateDataPortal <HasInvalidAsyncRule>();

            TestResults.Reinitialise();

            UnitTestContext context = GetContext();
            var             root    = dataPortal.Create();

            root.ValidationComplete += (o, e) =>
            {
                context.Assert.IsFalse(root.IsValid);
                context.Assert.AreEqual(1, root.GetBrokenRules().Count);
                context.Assert.AreEqual("Operation is not valid due to the current state of the object.", root.GetBrokenRules()[0].Description);
                context.Assert.Success();
            };
            root.Validate();
            context.Complete();
        }
示例#29
0
        public void AppDomainTestIsCalled()
        {
            IDataPortal <Basic.Root> dataPortal = _testDIContext.CreateDataPortal <Basic.Root>();

            TestResults.Reinitialise();
            int local = AppDomain.CurrentDomain.Id;

            Basic.Root r      = dataPortal.Create(new Basic.Root.Criteria());
            int        remote = r.CreatedDomain;

            if (System.Configuration.ConfigurationManager.AppSettings["CslaDataPortalProxy"] == null)
            {
                Assert.AreEqual(local, remote, "Local and Remote AppDomains should be the same");
            }
            else
            {
                Assert.IsFalse((local == remote), "Local and Remote AppDomains should be different");
            }
        }
        public void Test_Results_List_contains_More_simple_families()
        {
            //Given

            var firstResult  = new TestResults(id: "Ionescu", familyId: "I", score: 10);
            var secondResult = new TestResults(id: "Popescu", familyId: "P", score: 5);
            var thirdResult  = new TestResults(id: "Ionescu", familyId: "I", score: 15);

            var list = new List <TestResults> {
                firstResult, secondResult, thirdResult
            };

            //When
            var resultsMaximum = new ResultsMaximum(list);
            var filteredList   = resultsMaximum.GetMaxPerFamily();

            //Then
            Assert.Equal(new[] { thirdResult, secondResult }, filteredList);
        }
示例#31
0
        /// <summary>
        /// For executable files
        /// </summary>
        /// <param name="SolutionExe"></param>
        /// <param name="InputFile"></param>
        /// <param name="OutputFile"></param>
        /// <param name="TimeLimit"></param>
        /// <param name="MemoryLimit"></param>
        /// <param name="Result"></param>
        protected void RunSolutionExe(String SolutionExe, String InputFile, String OutputFile,
                                      double TimeLimit, int MemoryLimit, out TestResults Result, out long SolutionTime, out long SolutionMemory)
        {
            Result         = TestResults.RTE;
            SolutionTime   = 0;
            SolutionMemory = 0;

            ProcessStartInfo startInfo = new ProcessStartInfo();

            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardInput  = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardError  = true;
            startInfo.FileName       = SolutionExe;
            startInfo.CreateNoWindow = true;

            // Run the external process & wait for it to finish
            using (Process proc = Process.Start(startInfo))
            {
                using (AccessTokenHandle accessTokenHandle =
                           proc.GetAccessTokenHandle(
                               TokenAccessRights.AdjustPrivileges | TokenAccessRights.Query))
                {
                    #region Remove privileges using the same access token handle.
                    accessTokenHandle.RemovePrivilege(Privilege.Shutdown);
                    RemovePrivilege.Each(p => { try { accessTokenHandle.RemovePrivilege(p); } catch (Exception) {}; });
                    #endregion

                    try
                    {
                        RunSolution(proc, SolutionExe, InputFile, OutputFile, TimeLimit, MemoryLimit,
                                    out Result, out SolutionTime, out SolutionMemory);
                    }
                    catch (InvalidOperationException ex)
                    {
                        if (logger.IsDebugEnabled)
                        {
                            Console.WriteLine(DateTime.Now.ToString(culture) + " - Invalid operation exception on " + SolutionExe, ex.Message);
                        }
                    }
                } // using AccessToken
            }     // using Process
        }
示例#32
0
        public void TestAuthExecute()
        {
            IDataPortal <PermissionsRoot> dataPortal = _adminDIContext.CreateDataPortal <PermissionsRoot>();

            TestResults.Reinitialise();

            PermissionsRoot pr = dataPortal.Create();

            //should work, because we are now logged in as an admin
            pr.DoWork();

            Assert.AreEqual(true, System.Threading.Thread.CurrentPrincipal.IsInRole("Admin"));

            // TODO: This no longer makes sense; can't do this anymore?
            //set to null so the other testmethods continue to throw exceptions
            //Csla.ApplicationContext.User = new ClaimsPrincipal();

            Assert.AreEqual(false, System.Threading.Thread.CurrentPrincipal.IsInRole("Admin"));
        }
        public bool AddTestResults(TestResults testResults, SqlConnection conn = null)
        {
            bool succes = true;

            try
            {
                bool nullConnection = false;

                UtilitiesClass.CreateConnection(ref nullConnection, ref conn, base.GetConnectionString());

                using (var cmd = new SqlCommand("sp_insertTestResults", conn))
                {
                    cmd.Parameters.AddWithValue("@STUDENT_ID", testResults.StudentID);
                    cmd.Parameters.AddWithValue("@TEST_ID", testResults.TestID);
                    cmd.Parameters.AddWithValue("@MARK", testResults.Mark);
                    cmd.Parameters.AddWithValue("@POINTS", testResults.Points);
                    cmd.Parameters.AddWithValue("@ANSWERS_RESULT", testResults.AnswersResult);
                    cmd.Parameters.AddWithValue("@TEST_RESULT_DATE", testResults.TestResultDate);
                    cmd.Parameters.AddWithValue("@NR_OF_CORRECT_ANSWERS", testResults.NrOfCorrectAnswers);
                    cmd.Parameters.AddWithValue("@NR_OF_WRONG_ANSWERS", testResults.NrOfWrongAnswers);
                    cmd.Parameters.AddWithValue("@NR_OF_UNFILLED_ANSWERS", testResults.NrOfUnfilledAnswers);
                    cmd.CommandType = CommandType.StoredProcedure;

                    if (nullConnection)
                    {
                        conn.Open();
                    }

                    cmd.ExecuteNonQuery();

                    if (conn.State == ConnectionState.Open && nullConnection)
                    {
                        conn.Close();
                    }
                }
            }
            catch (Exception e)
            {
                _log.Error("AddTestResults() error. TestId: " + testResults.TestID, e);
            }

            return(succes);
        }
示例#34
0
        public void TestUFGVisualViewport()
        {
            JsonSerializer serializer = JsonUtils.CreateSerializer();
            IWebDriver     driver     = SeleniumUtils.CreateChromeDriver();
            EyesRunner     runner     = new VisualGridRunner(10);
            Eyes           eyes       = new Eyes(runner);

            TestUtils.SetupLogging(eyes);
            Configuration config        = eyes.GetConfiguration();
            IosDeviceInfo iosDeviceInfo = new IosDeviceInfo(IosDeviceName.iPhone_11_Pro);

            config.AddBrowser(iosDeviceInfo);
            eyes.SetConfiguration(config);
            try
            {
                eyes.Open(driver, "Eyes Selenium SDK", "Eyes Selenium SDK - UFG Visual Viewport Test");

                string inputJson = CommonUtils.ReadResourceFile("Test.Eyes.Selenium.DotNet.Resources.Misc.TestUFGVisualViewport_Input.json");
                RenderStatusResults renderStatusResults = serializer.Deserialize <RenderStatusResults>(inputJson);

                driver.Url = "https://applitools.github.io/demo/TestPages/DynamicResolution/desktop.html";
                eyes.Check(Target.Window().Fully());
                eyes.Close(false);

                TestResultsSummary resultsSummary = runner.GetAllTestResults(false);
                Assert.AreEqual(1, resultsSummary.Count);
                TestResults    results        = resultsSummary[0].TestResults;
                SessionResults sessionResults = TestUtils.GetSessionResults(eyes.ApiKey, results);

                Assert.AreEqual(1, sessionResults.ActualAppOutput.Length);
                ActualAppOutput appOutput = sessionResults.ActualAppOutput[0];
                Assert.AreEqual(980, appOutput.Image.Viewport.Width);
                Assert.AreEqual(1659, appOutput.Image.Viewport.Height);

                Assert.AreEqual(375, sessionResults.Env.DisplaySize.Width);
                Assert.AreEqual(812, sessionResults.Env.DisplaySize.Height);
            }
            finally
            {
                eyes.AbortIfNotClosed();
                driver.Quit();
            }
        }
示例#35
0
 public BuildTile Convert(BuildDto buildDto, TestResults testResultsDto)
 {
     return(new BuildTile
     {
         Id = buildDto.Id,
         BuildReportUrl = buildDto.Links.Web.Href,
         RequestedByName = buildDto.RequestedFor.DisplayName,
         Status = string.IsNullOrEmpty(buildDto.Result) ? buildDto.Status : buildDto.Result,
         TotalNumberOfTests = testResultsDto?.TotalTests ?? 0,
         PassedNumberOfTests = testResultsDto?.PassedTests ?? 0,
         TeamProject = _displayTransformer.Tranform(buildDto.Project.Name),
         BuildDefinition = _displayTransformer.Tranform(buildDto.Definition.Name),
         StartBuildDateTime = buildDto.StartTime,
         FinishBuildDateTime = buildDto.FinishTime,
         Branch = ConvertBranchName(buildDto.SourceBranch),
         RepoName = _displayTransformer.Tranform(buildDto.Repository.Name),
         UserEmail = buildDto.RequestedFor.UniqueName.ToLower()
     });
 }
示例#36
0
        public UserInfo GetEncryptedInfo()
        {
            UserInfo info = new UserInfo()
            {
                Id             = Id,
                Name           = Name,
                RegDate        = RegDate,
                EmailIsVisible = EmailIsVisible,
                TestsCompleted = 0,
                TestsCreated   = 0,
                Email          = Email
            };

            if (TestResults != null)
            {
                info.TestsCompleted = TestResults.Count();
            }

            if (Tests != null)
            {
                info.TestsCreated = Tests.Count();
            }

            if (!EmailIsVisible)
            {
                string tmp   = new string(Email.TakeWhile(c => c != '@').ToArray());
                int    count = 2;
                if (tmp.Length < 4)
                {
                    count = 1;
                }
                if (tmp.Length == 1)
                {
                    count = 0;
                }
                tmp        = new string(tmp.Take(count).ToArray()) + new string('*', tmp.Length - count);
                info.Email = tmp + new string(Email.SkipWhile(c => c != '@').ToArray());
            }
            info.Password = new string('*', 6);

            return(info);
        }
示例#37
0
        /// <summary>
        /// Opens populates the tab with the results contained in the specified file.
        /// </summary>
        /// <param name="strResultFile">The file containing the results to open.</param>
        //  Revision History
        //  MM/DD/YY Who Version ID Number Description
        //  -------- --- ------- -- ------ -------------------------------------------
        //  08/28/09 RCG 2.30.00           Created
        //  09/19/14 jrf 4.00.63 WR 534158 Modified way results and result nodes are set.
        //  09/19/14 jrf 4.00.63 WR 534159 Adding the word results after each test name when displaying
        //                                 the results of each test.
        public void OpenResultFile(string strResultFile)
        {
            FileInfo    CurrentFileInfo    = new FileInfo(strResultFile);
            TestResults CurrentTestResults = new TestResults();

            m_strOpenFilePath = strResultFile;
            Text = CurrentFileInfo.Name;

            CurrentTestResults.Load(m_strOpenFilePath);

            if (CurrentTestResults.TestRuns != null && CurrentTestResults.TestRuns.Count > 0)
            {
                TestRun CurrentTestRun = CurrentTestResults.TestRuns[0];

                m_MeterID  = CurrentTestRun.MeterID;
                m_TestDate = CurrentTestRun.TestDate;

                AddResultNode(Resources.TestInformation, "", "");
                AddResult(Resources.ElectronicSerialNumber, Resources.OK, m_MeterID, "", "");
                AddResult(Resources.TestDate, Resources.OK, m_TestDate.ToString("G", CultureInfo.CurrentCulture), "", "");
                AddResult(Resources.ProgramUsed, Resources.OK, Path.GetFileNameWithoutExtension(CurrentTestRun.ProgramName), "", "");
                AddResult(Resources.DeviceType, Resources.OK, CurrentTestRun.MeterType, "", "");
                AddResult(Resources.SoftwareVersion, Resources.OK, CurrentTestRun.SWVersion, "", "");

                // Add each of the tests that are contained in the file
                foreach (Test CurrentTest in CurrentTestRun.Tests)
                {
                    // Add the node for the test
                    AddResultNode(CurrentTest.Name + " " + Resources.Results, CurrentTest.Result, CurrentTest.Reason);

                    // Add each of the test details
                    foreach (TestDetail CurrentTestDetail in CurrentTest.TestDetails)
                    {
                        AddResult(CurrentTestDetail.Name,
                                  CurrentTestDetail.Result,
                                  CurrentTestDetail.Details,
                                  CurrentTestDetail.AdditionalDetails,
                                  CurrentTestDetail.Reason);
                    }
                }
            }
        }
示例#38
0
        public void SaveOldRoot()
        {
            TestResults.Reinitialise();
            Csla.Test.Basic.Root root = GetRoot("old");

            root.Data = "saved";
            Assert.AreEqual("saved", root.Data);
            Assert.AreEqual(true, root.IsDirty, "IsDirty");
            Assert.AreEqual(true, root.IsValid, "IsValid");

            TestResults.Reinitialise();
            root = root.Save();

            Assert.IsNotNull(root);
            Assert.AreEqual("Updated", TestResults.GetResult("Root"));
            Assert.AreEqual("saved", root.Data);
            Assert.AreEqual(false, root.IsNew, "IsNew");
            Assert.AreEqual(false, root.IsDeleted, "IsDeleted");
            Assert.AreEqual(false, root.IsDirty, "IsDirty");
        }
示例#39
0
        public void NoDoubleInit()
        {
            IDataPortal <HasPerTypeRules2> dataPortal = _testDIContext.CreateDataPortal <HasPerTypeRules2>();

            UnitTestContext context = GetContext();

            TestResults.Reinitialise();
            TestResults.Add("Shared", "0");

            HasPerTypeRules2 root = dataPortal.Create();

            int expected = (_initialized ? 0 : 1);
            int actual   = int.Parse(TestResults.GetResult("Shared"));

            context.Assert.AreEqual(expected, actual, "Rules should init just once");

            _initialized = true;
            context.Assert.Success();
            context.Complete();
        }
示例#40
0
        public void BasicEquality()
        {
            TestResults.Reinitialise();
            Root r1 = NewRoot();

            r1.Data = "abc";
            Assert.AreEqual(true, r1.Equals(r1), "objects should be equal on instance compare");
            Assert.AreEqual(true, Equals(r1, r1), "objects should be equal on static compare");

            TestResults.Reinitialise();
            Root r2 = NewRoot();

            r2.Data = "xyz";
            Assert.AreEqual(false, r1.Equals(r2), "objects should not be equal");
            Assert.AreEqual(false, Equals(r1, r2), "objects should not be equal");

            Assert.AreEqual(false, r1.Equals(null), "Objects should not be equal");
            Assert.AreEqual(false, Equals(r1, null), "Objects should not be equal");
            Assert.AreEqual(false, Equals(null, r2), "Objects should not be equal");
        }
        public void TestReplaceLast()
        {
            Eyes eyes = Setup();

            eyes.Open(nameof(TestReplaceLast), nameof(TestReplaceLast));

            var path1 = Path_("paychex1a.png");
            var path2 = Path_("dropbox1a-chrome.png");

            eyes.Check(Target.Image(path1).WithName("step 1"));
            eyes.Check(Target.Image(path2).WithName("step 2"));
            eyes.Check(Target.Image(path1).WithName("step 3"));
            eyes.Check(Target.Image(path2).WithName("step 3 (replaced)").ReplaceLast());
            TestResults result = Teardown(eyes);

            Assert.AreEqual(3, result.Steps);
            Assert.AreEqual("step 1", result.StepsInfo[0].Name);
            Assert.AreEqual("step 2", result.StepsInfo[1].Name);
            Assert.AreEqual("step 3 (replaced)", result.StepsInfo[2].Name);
        }
示例#42
0
 public bool UpdateAnswer(string id, int answer, int task)
 {
     try
     {
         TestResults testResults = new TestResults();
         testResults.ID       = database.TestResults.Count() + 1;
         testResults.PersonID = id;
         testResults.TaskID   = task;
         testResults.Answer   = answer;
         database.TestResults.Add(testResults);
         var model = database.Intern.Find(id);
         model.Result = model.Result + 1;
         database.SaveChanges();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#43
0
        public void SetTestResults(TestResults results)
        {
            int passedTests = 0;
            int failedTests = 0;

            foreach(var resultList in results.Values) {
                foreach(var result in resultList) {
                    if(result.WasSuccessful) {
                        passedTests++;
                    } else {
                        failedTests++;
                    }
                }
            }

            int totalTests = passedTests + failedTests;

            _failedTestLabel.Text = string.Format("{0}/{1} failed", failedTests, totalTests);
            _passingTestLabel.Text = string.Format("{0}/{1} passed", passedTests, totalTests);
        }
示例#44
0
        string BuildFailDisplayText(TestResults results)
        {
            if (results.Errors == results.Total && results.Errors == 1)
            {
                return "1 test failed";
            }

            if(results.Errors == results.Total)
            {
                return string.Format("{0} tests failed", results.Errors);
            }

            int passedTests = results.Total - results.Errors;

            if (results.Errors == 1 && passedTests == 1)
            {
               return string.Format("{0} test passed, {1} test failed", passedTests, results.Errors);
            }

            return string.Format("{0} tests passed, {1} tests failed", passedTests, results.Errors);
        }
示例#45
0
        public static TestResults TestFormat(int formatCount, int iterations, Action<string,object[]> action)
        {
            object[] valuesdict = new object[formatCount];
            string template = "hello ";
            for (int i = 0; i < formatCount; i++)
            {
                template += "{" + i + "} text112";
                valuesdict[i] = i;
            }

            Stopwatch sw = new Stopwatch();
            //prime the string format, so it will be more realistic
            action(template, valuesdict);

            for (var i = 0; i < iterations; i++)
            {
                sw.Stop();
                for (int fc = 0; fc < formatCount; fc++)
                {
                    valuesdict[fc] = i;
                }
                sw.Start();
                action(template, valuesdict);
                sw.Stop();
            }



            TestResults tr = new TestResults
            {
                 ParameterCount = formatCount,
                 ElapsedMilliseconds = sw.ElapsedMilliseconds
            };

            return tr;
        }
示例#46
0
        void Display(TestResults results, Configuration configuration)
        {
            if (configuration.RunnerDisplay.Contains("File") || configuration.RunnerDisplay.Contains("Beacons"))
                SerializeResultsToFile(results);

            if (configuration.RunnerDisplay.Contains("Growl"))
            {
                IGrowlWrapper growl = new GrowlWrapper();
                var growlDisplay = new GrowlDisplay.GrowlDisplay(growl);

                growlDisplay.DisplayNotification(results);
            }
        }
示例#47
0
 private string GetTestResultName(TestResults testResults)
 {
     return testResults.ToString();
 }
示例#48
0
 private static int GetImageIndexForStatus(TestResults result)
 {
     return (int)result;
 }
示例#49
0
        /// <summary>
        /// sets status of the test
        /// </summary>
        private void SetTestStatus(ListViewItem item, TestResults result)
        {
            if (this._testListView.InvokeRequired)
            {
                this._testListView.BeginInvoke(new MethodInvoker(delegate() { SetTestStatus(item, result); }));
            }
            else
            {
                ListViewItem.ListViewSubItem statusSubItem = item.SubItems[2];
                Color statusTextColor = Color.Black;
                Color statusBackgroundColor = Color.Transparent;

                switch (result)
                {
                    case TestResults.Succeed: statusTextColor = Color.Green; break;
                    case TestResults.Failed: statusTextColor = Color.Red; break;

                    case TestResults.UnexpectedError:
                        statusTextColor = Color.White;
                        statusBackgroundColor = Color.Red;
                        break;
                }

                statusSubItem.Text = GetTestResultName(result);
                statusSubItem.BackColor = statusBackgroundColor;
                statusSubItem.ForeColor = statusTextColor;
                item.ImageIndex = GetImageIndexForStatus(result);
                item.EnsureVisible();
            }
        }
示例#50
0
 public TestHandler(string backendurl, Options options, TestResults results)
 {
     m_options = options;
     m_backendurl = backendurl;
     m_results = results;
 }
示例#51
0
 private void PerformTest(TestResults result = TestResults.Ok)
 {
     if ( testStarted )
         {
         try
             {
             using ( SqlConnection conn = new SqlConnection(Settings.Default.ConnectionString) )
                 {
                 conn.Open();
                 using ( SqlCommand cmd = conn.CreateCommand() )
                     {
                     cmd.CommandText = "update SMSDeliverServiceTest set DateEnd = GETDATE(), Result = @Status where Id = @Id";
                     cmd.Parameters.AddWithValue("@Id", testId);
                     cmd.Parameters.AddWithValue("@Status", ( int ) result);
                     cmd.ExecuteNonQuery();
                     testId = 0;
                     testStarted = false;
                     lastChecked = DateTime.Now.Ticks;
                     if ( OnTestEnded != null )
                         {
                         OnTestEnded(result);
                         }
                     }
                 }
             }
         catch ( Exception exp )
             {
             NotifyOnError(exp);
             }
         }
 }
示例#52
0
 bool IsSuccess(TestResults results)
 {
     return results.Errors == 0 && results.Failures == 0 && results.Inconclusive == 0;
 }
示例#53
0
        public static TestStatistics TestBSP(TestJob job, LoadedBSP bsp, string temporaryDirectory)
        {
            TestStatistics stats = new TestStatistics();
            Directory.CreateDirectory(temporaryDirectory);
            using (var r = new TestResults(Path.Combine(temporaryDirectory, "bsptest.log")))
            {
                LoadedBSP.LoadedMCU[] MCUs;
                if (job.DeviceRegex == null)
                    MCUs = bsp.MCUs.ToArray();
                else
                {
                    var rgFilter = new Regex(job.DeviceRegex);
                    MCUs = bsp.MCUs.Where(mcu => rgFilter.IsMatch(mcu.ExpandedMCU.ID)).ToArray();
                }

                if (job.SkippedDeviceRegex != null)
                {
                    var rg = new Regex(job.SkippedDeviceRegex);
                    MCUs = MCUs.Where(mcu => !rg.IsMatch(mcu.ExpandedMCU.ID)).ToArray();
                }

                var loadedRules = job.RegisterRenamingRules?.Select(rule => new LoadedRenamingRule(rule))?.ToArray();
                var noValidateReg = job.NonValidatedRegisters;

                foreach (var sample in job.Samples)
                {
                    r.BeginSample(sample.Name);
                    int cnt = 0, failed = 0, succeeded = 0;
                    foreach (var mcu in MCUs)
                    {
                        if (string.IsNullOrEmpty(mcu.ExpandedMCU.ID))
                            throw new Exception("Invalid MCU ID!");

                        var extraParams = job.DeviceParameterSets?.FirstOrDefault(s => s.DeviceRegexObject?.IsMatch(mcu.ExpandedMCU.ID) == true);

                        string mcuDir = Path.Combine(temporaryDirectory, mcu.ExpandedMCU.ID);
                        DateTime start = DateTime.Now;
                        var result = TestMCU(mcu, mcuDir + sample.TestDirSuffix, sample, extraParams, loadedRules, noValidateReg);
                        Console.WriteLine($"[{(DateTime.Now - start).TotalMilliseconds:f0} msec]");
                        if (result == TestResult.Failed)
                            failed++;
                        else if (result == TestResult.Succeeded)
                            succeeded++;

                        r.LogTestResult(mcu.ExpandedMCU.ID, result);

                        cnt++;
                        Console.WriteLine("{0}: {1}% done ({2}/{3} devices, {4} failed)", sample.Name, (cnt * 100) / MCUs.Length, cnt, MCUs.Length, failed);
                    }

                    if (succeeded == 0)
                        throw new Exception("Not a single MCU supports " + sample.Name);
                    r.EndSample();

                    stats.Passed += succeeded;
                    stats.Failed += failed;
                }
            }
            return stats;
        }
示例#54
0
 public TestResultInfo(TestResults result)
 {
     this.Result = result;
 }
示例#55
0
        void BuildTestSuiteProjectNodes(string testRunTime, TestResults results, MSpec mspecResults)
        {
            foreach (var assembly in mspecResults.Assembly)
            {
                var assemblySuite = new TestSuite();
                assemblySuite.TestSuiteType = "Project";
                assemblySuite.Executed = true;
                assemblySuite.Time = testRunTime;

                assemblySuite.Asserts = GetAssemblySpecificationCount(assembly);

                assemblySuite.Name = Path.Combine(Path.GetDirectoryName(mspecResults.Assembly[0].Location), mspecResults.Assembly[0].Name);

                if (GetAssemblySpecificationFailures(assembly) == 0 )
                {
                    assemblySuite.Result = "Success";
                    assemblySuite.Success = true;
                }
                else
                {
                    assemblySuite.Result = "Failure";
                    assemblySuite.Success = false;
                }

                var assemblyResults = new Results();
                assemblySuite.Results = assemblyResults;

                BuildTestSuiteNameSpaceNodes(testRunTime, assemblyResults, assembly);

                results.TestSuite = assemblySuite;
            }
        }
示例#56
0
        TestResults CompileResults()
        {
            var mspecResults = LoadMSpecResults();

            if (mspecResults == null)
                return InconclusiveResults();

            var testRunTime = FormatTestRunTime(mspecResults);

            var results = new TestResults
                              {
                                  Errors = GetTotalFailures(mspecResults),
                                  Failures = 0,
                                  Inconclusive = GetTotalNotImplemented(mspecResults),
                                  Total = GetTotalSpecificationCount(mspecResults),
                                  Time = FormatCurrentTime(),
                                  Date = FormatCurrentDate(),
                                  Enviroument = BuildEnviroument(),
                                  CultureInfo = BuildCultureInformation()
                              };

            BuildTestSuiteProjectNodes(testRunTime, results, mspecResults);

            return results;
        }
示例#57
0
        public static TestStatistics TestVendorSamples(VendorSampleDirectory samples, string bspDir, string temporaryDirectory, double testProbability = 1)
        {
            const string defaultToolchainID = "SysGCC-arm-eabi-5.3.0";
            var toolchainPath = (string)Registry.CurrentUser.OpenSubKey(@"Software\Sysprogs\GNUToolchains").GetValue(defaultToolchainID);
            if (toolchainPath == null)
                throw new Exception("Cannot locate toolchain path from registry");

            var toolchain = LoadedToolchain.Load(Environment.ExpandEnvironmentVariables(toolchainPath), new ToolchainRelocationManager());
            var bsp = LoadedBSP.Load(new BSPManager.BSPSummary(Environment.ExpandEnvironmentVariables(Path.GetFullPath(bspDir))), toolchain);

            TestStatistics stats = new TestStatistics();
            int cnt = 0, failed = 0, succeeded = 0;
            LoadedBSP.LoadedMCU[] MCUs = bsp.MCUs.ToArray();
            string outputDir = Path.Combine(temporaryDirectory, "VendorSamples");
            if (!Directory.Exists(outputDir))
                Directory.CreateDirectory(outputDir);
            int sampleCount = samples.Samples.Length;
            Random rng = new Random();
            using (var r = new TestResults(Path.Combine(temporaryDirectory, "bsptest.log")))
            {
                foreach (var vs in samples.Samples)
                {
                    LoadedBSP.LoadedMCU mcu;

                    try
                    {
                        var rgFilterID = new Regex(vs.DeviceID.Replace('x', '.'), RegexOptions.IgnoreCase);
                        mcu = bsp.MCUs.Where(f => rgFilterID.IsMatch(f.ExpandedMCU.ID)).ToArray()?.First();
                        vs.DeviceID = mcu.ExpandedMCU.ID;
                    }
                    catch (Exception ex)
                    {
                        r.ExceptionSample(ex.Message, "mcu " + vs.DeviceID + " not found in bsp");
                        Console.WriteLine("bsp have not mcu:" + vs.DeviceID);
                        continue;
                    }

                    if (testProbability < 1 && rng.NextDouble() > testProbability)
                    {
                        cnt++;
                        continue;
                    }

                    bool aflSoftFPU = true;
                    string mcuDir = Path.Combine(temporaryDirectory, "VendorSamples", vs.UserFriendlyName);
                    if (!Directory.Exists(mcuDir))
                        Directory.CreateDirectory(mcuDir);
                    if (vs.UserFriendlyName.ToUpper().Contains("RTOS"))
                        aflSoftFPU = false;
                    DateTime start = DateTime.Now;
                    var result = TestVendorSample(mcu, vs, mcuDir, aflSoftFPU, samples);

                    Console.WriteLine($"[{(DateTime.Now - start).TotalMilliseconds:f0} msec]");

                    if (result == TestResult.Failed)
                        failed++;
                    else if (result == TestResult.Succeeded)
                        succeeded++;

                    r.LogTestResult(vs.UserFriendlyName, result);
                    cnt++;
                    Console.WriteLine("{0}: {1}% done ({2}/{3} projects, {4} failed)", vs.UserFriendlyName, (cnt * 100) / sampleCount, cnt, sampleCount, failed);
                }
            }

            stats.Passed += succeeded;
            stats.Failed += failed;
            if (samples is ConstructedVendorSampleDirectory)
            {
                (samples as ConstructedVendorSampleDirectory).ToolchainDirectory = toolchainPath;
                (samples as ConstructedVendorSampleDirectory).BSPDirectory = Path.GetFullPath(bspDir);
            }
            return stats;
        }
示例#58
0
        void SerializeResultsToFile(TestResults results)
        {
            var serializer = new TheSerializer();

            string xml = serializer.ToXml(results);

            string solutionPath = Path.GetDirectoryName(_configuration.SolutionPath);

            string testFilePath = Path.Combine(solutionPath, "TestResult.xml");

            File.WriteAllText(testFilePath, xml);
        }
示例#59
0
        TestResults BuildFailedResult()
        {
            var results = new TestResults();
            results.Errors = 0;
            results.Failures = 0;
            results.Inconclusive = 1;
            results.Total = 1;
            results.Time = FormatCurrentTime();
            results.Date = FormatCurrentDate();
            results.Enviroument = BuildEnviroument();
            results.CultureInfo = BuildCultureInformation();

            return results;
        }
示例#60
0
        TestResults InconclusiveResults()
        {
            var results = new TestResults
                              {
                                  Errors = 0,
                                  Failures = 0,
                                  Inconclusive = 1,
                                  Total = 1,
                                  Time = FormatCurrentTime(),
                                  Date = FormatCurrentDate(),
                                  Enviroument = BuildEnviroument(),
                                  CultureInfo = BuildCultureInformation()
                              };

            return results;
        }