Пример #1
0
        public void SimulateTestPlan()
        {
            var rl      = new LogResultListener();
            var planrun = new TestPlanRun();

            planrun.StartTime = DateTime.Now;
            planrun.Duration  = TimeSpan.FromSeconds(1);
            planrun.Parameters["TestPlanName"] = "test";

            // An issue was found where first setting planrun.Parameters["Verdict"] to a string and
            // then getting it as a Verdict.
            planrun.Parameters["Verdict"] = "Pass";
            Assert.AreEqual(Verdict.Pass, planrun.Verdict);
            rl.OnTestPlanRunStart(planrun);

            string testString = "Test Test Test";

            var ms = new MemoryStream(Encoding.UTF8.GetBytes(testString));

            rl.OnTestPlanRunCompleted(planrun, ms);
            var file = rl.FilePath.Expand(planrun);

            try
            {
                Assert.AreEqual(testString, File.ReadAllText(file));
            }
            finally
            {
                File.Delete(file);
            }
        }
Пример #2
0
        public void LogResultListener()
        {
            LogResultListener log = new LogResultListener {
                FilePath = new MacroString {
                    Text = "logResult.txt"
                }
            };
            var expanded = log.FilePath.Expand();

            // If debugging the LogResultListener will just rename the file since it might exist
            if (System.IO.File.Exists(expanded))
            {
                System.IO.File.Delete(expanded);
            }

            ResourceTest.TestConformance(log);
            var testPlan = TestStepTest.CreateGenericTestPlan();

            testPlan.Steps.Add(new TestStepEmit());
            ResultSettings.Current.Add(log);
            var run = testPlan.Execute();

            var logText = System.IO.File.ReadAllText(expanded, System.Text.Encoding.ASCII);

            StringAssert.Contains("This was called", logText);

            ResultSettings.Current.Remove(log);
        }
Пример #3
0
        void RunTestPlanCommon()
        {
            // Add database result output:
            PlanRunCollectorListener pl = new PlanRunCollectorListener();

            const string outputDir = @"PlatformTests/";

            if (!Directory.Exists(outputDir))
            {
                Directory.CreateDirectory(outputDir);
            }

            // Set log file path:
            LogResultListener log = ResultSettings.Current.GetDefault <LogResultListener>();

            if (log == null)
            {
                log = new LogResultListener();
                ResultSettings.Current.Add(log);
            }
            string logFilePath = $"{outputDir}/{plan.Name}.log";

            log.FilePath.Text = logFilePath;
            TestPlanRun planRun = plan.Execute(ResultSettings.Current.Concat(new IResultListener[] { pl }));

            List <string> allowedMessages = new List <string>
            {
                "DUT chipset is not verified to work with this application."
            };

            ResultSettings.Current.Remove(log);
            Log.RemoveListener(trace);
            trace.AssertErrors(allowedMessages);
            foreach (var stepRun in pl.StepRuns)
            {
                Assert.IsTrue(stepRun.Verdict <= Verdict.Pass, "TestPlan ran to completion but verdict was '{1}' on step '{0}'.\r\nLog:\r\n{2}",
                              stepRun.TestStepName,
                              stepRun.Verdict, trace.GetLog());
            }
        }