示例#1
0
        }         // constructor

        public void SetResult(StepResults stepResult, string outcum)
        {
            this.endTime  = DateTime.UtcNow;
            this.executed = true;
            this.result   = stepResult;
            this.outcome  = outcum;
        }         // SetResult
示例#2
0
 public virtual void Dump()
 {
     Console.WriteLine("Result: {0}", Success);
     Console.WriteLine("Duration: {0}ms", Duration.TotalMilliseconds);
     Console.WriteLine("Step Results:");
     StepResults.ForEach(s => Console.WriteLine("\t{0}", s));
 }
示例#3
0
 void Ex02()
 {
     Given("GivenStep that has an arrangement that does not throw any exceptions", () => Step = FixtureSteps.CreateGivenStep(() => { }));
     Given("a result of ThenStep", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateThenStep()).Passed().Build()));
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then("InvalidFixtureStepException should be thrown", exc => exc.GetType() == typeof(InvalidFixtureStepException));
 }
示例#4
0
        public void WriteResults(StepResults results, ITestContext context)
        {
            if (!_cell.IsResult)
            {
                WritePreview(context);
                return;
            }

            var actual = results.HasActual(_cell.Key) ? results.GetActual(_cell.Key) : "MISSING";

            if (results.IsInException(_cell.Key))
            {
                Text("Error!");
                AddClass(HtmlClasses.EXCEPTION);

                return;
            }

            if (results.IsFailure(_cell.Key))
            {
                var expected = _step.Get(_cell.Key);
                string text = "{0}, but was '{1}'".ToFormat(expected, actual);
                Text(text);
                AddClass(HtmlClasses.FAIL);
            }
            else
            {
                Text(context.GetDisplay(actual));
                AddClass(HtmlClasses.PASS);
            }
        }
示例#5
0
        public override StepResults Execute()
        {
            try {
                Log.Debug("Start of step {0} for {1}...", Name, OuterContextDescription);

                StepResults nextStep = Run();

                Log.Debug(
                    "End of step {0} with result {1} for {2}.",
                    Name,
                    Outcome,
                    OuterContextDescription
                    );

                CollectOutputValues();

                return(nextStep);
            } catch (Exception e) {
                Log.Alert(
                    e,
                    "Exception during step {0} while executing for {1}.",
                    Name,
                    OuterContextDescription
                    );

                return(StepResults.AbnormalShutdown);
            }     // try
        }         // Execute
    void Ex03()
    {
        var thenStepCompleted = false;

        Given("async ThenStep that has an assertion with Exception that does not throw any exceptions", () =>
        {
            Step = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ =>
            {
                await Task.Delay(100);
                thenStepCompleted = true;
            });
            ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, Step);
        });
        Given("async next ThenStep that asserts the Exception that is thrown at WhenStep", () =>
        {
            NextStep = FixtureSteps.CreateThenStep <ArgumentNullException>(async _ =>
            {
                await Task.Delay(100);
                thenStepCompleted = true;
            });
            ExpectedNextResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Passed, NextStep);
        });
        When("the given ThenStep is run", () =>
        {
            Result = RunnerOf(Step).Run(StepResults).Build();
            StepResults.Add(Result);
        });
        Then("the given ThenStep should be awaited", () => thenStepCompleted);
        Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);

        thenStepCompleted = false;
        When("the given next ThenStep is run", () => Result = RunnerOf(NextStep).Run(StepResults).Build());
        Then("the given next ThenStep should be awaited", () => thenStepCompleted);
        Then($"the result should be as follows:{ExpectedNextResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedNextResult);
    }
示例#7
0
 public Results(SentenceTag tag, ITestContext context)
 {
     _tag     = tag;
     _context = context;
     _results = _context.ResultsFor(tag._step);
     _step    = tag._step;
 }
示例#8
0
        public void capture_exception_text()
        {
            var errors = new StepResults();
            errors.CaptureException(new NotImplementedException().ToString());

            errors.ExceptionText.ShouldContain("NotImplementedException");
        }
示例#9
0
        public void capturing_an_exception_means_that_has_errors_should_be_true()
        {
            var errors = new StepResults();
            errors.HasErrors().ShouldBeFalse();

            errors.CaptureException(new NotImplementedException().ToString());
            errors.HasErrors().ShouldBeTrue();
        }
示例#10
0
        public void capture_exception_text()
        {
            var errors = new StepResults();

            errors.CaptureException(new NotImplementedException().ToString());

            errors.ExceptionText.ShouldContain("NotImplementedException");
        }
示例#11
0
        public void mark_as_failure()
        {
            var errors = new StepResults();

            errors.MarkFailure("key1");

            errors.IsFailure("key1").ShouldBeTrue();
            errors.IsFailure("key2").ShouldBeFalse();
        }
示例#12
0
        void ITestStream.StartParagraph(Paragraph paragraph, IStep step)
        {
            _paragraphResults = _context.ResultsFor(step);
            _paragraphResults.MoveFirst();

            var tag = new ParagraphTag(paragraph, step);

            _document.Push(tag);
        }
示例#13
0
        public void store_and_retrieve_a_result()
        {
            var result = new List<SetRow>();
            var results = new StepResults();

            results.SetResult(result, "key");

            results.GetResult<List<SetRow>>("key").ShouldBeTheSameAs(result);
        }
示例#14
0
        public void capturing_an_exception_means_that_has_errors_should_be_true()
        {
            var errors = new StepResults();

            errors.HasErrors().ShouldBeFalse();

            errors.CaptureException(new NotImplementedException().ToString());
            errors.HasErrors().ShouldBeTrue();
        }
示例#15
0
 void Ex10()
 {
     Given("ThenStep that has an assertion with Exception that returns boolean", () => Step = FixtureSteps.CreateThenStep(new Action <Exception>(exc => throw new Exception())));
     Given("a result of GivenStep that does not have an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Failed(new Exception()).Build()));
     When("the given ThenStep is run", () => RunnerOf(Step).Run(StepResults).Build());
     Then("the status of the result of the latest WhenStep should be Passed", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Status == FixtureStepStatus.Passed);
     Then("the exception of the result of the latest WhenStep should be null", () => StepResults.GetLatestStepResultsOf <WhenStep>().First().Exception == null);
 }
示例#16
0
        public void marking_a_missing_value_should_set_HasErrors_to_true()
        {
            var errors = new StepResults();

            errors.HasErrors().ShouldBeFalse();

            errors.MarkMissingValue("a");

            errors.HasErrors().ShouldBeTrue();
        }
示例#17
0
        public void store_and_retrieve_a_result()
        {
            var result  = new List <SetRow>();
            var results = new StepResults();

            results.SetResult(result, "key");


            results.GetResult <List <SetRow> >("key").ShouldBeTheSameAs(result);
        }
示例#18
0
        public void capture_exception_with_frame()
        {
            var errors = new StepResults();
            errors.CaptureException("anything");

            errors.MoveFrame();

            errors.HasErrors().ShouldBeFalse();
            errors.ExceptionText.ShouldBeEmpty();
        }
示例#19
0
        public void reset_clears_failure_keys()
        {
            var errors = new StepResults();

            errors.MarkFailure("key1");

            errors.Clear();

            errors.IsInException("key1").ShouldBeFalse();
        }
示例#20
0
        public void MarkMissingStep()
        {
            var errors = new StepResults();

            errors.MarkMissingValue("a");

            errors.ExceptionText.ShouldEqual("\"a\" is not defined.");

            errors.MarkMissingValue("b");
            errors.ExceptionText.ShouldEqual("\"a\" is not defined.\n\"b\" is not defined.");
        }
示例#21
0
        public void mark_as_exception()
        {
            var errors = new StepResults();

            errors.MarkFormatFailure("key1");
            errors.MarkMissingValue("key2");

            errors.IsInException("key1").ShouldBeTrue();
            errors.IsInException("key2").ShouldBeTrue();
            errors.IsInException("key3").ShouldBeFalse();
        }
示例#22
0
        public void capture_exception_with_frame()
        {
            var errors = new StepResults();

            errors.CaptureException("anything");

            errors.MoveFrame();

            errors.HasErrors().ShouldBeFalse();
            errors.ExceptionText.ShouldBeEmpty();
        }
示例#23
0
 void Ex03()
 {
     Given("GivenStep that has an arrangement that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateGivenStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step);
     });
     Given("a result of GivenStep that has an exception", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Failed(new Exception()).Build()));
     When("the given GivenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
 public void AddStepResult(Step step)
 {
     if (!StepResults.Any(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value))
     {
         StepResults.Add(new StepResult(step));
     }
     else
     {
         var stepResult = StepResults.First(sr => sr.Step.SelectorId == step.SelectorId && sr.Step.Value == step.Value);
         stepResult.Attempts++;
     }
 }
示例#25
0
        public void capture_error_on_the_second_frame()
        {
            var errors = new StepResults();
            errors.MoveFrame();
            errors.CaptureException("anything");

            errors.MoveFirst();
            errors.HasErrors().ShouldBeFalse();

            errors.MoveFrame();
            errors.HasErrors().ShouldBeTrue();
        }
 void Ex08()
 {
     Given("WhenStep that has an action that does not throw any exceptions", () =>
     {
         Step           = FixtureSteps.CreateWhenStep(() => { });
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, Step);
     });
     Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build()));
     When("the given WhenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
示例#27
0
        public void SetUp()
        {
            cell          = Cell.For <string>("name");
            cell.IsResult = true;
            step          = new Step().With("name:Jeremy");

            result = new StepResults();
            result.SetActual("name", "Jeremy");

            tag = new CellTag(cell, step);
            tag.WriteResults(result, new TestContext());
        }
示例#28
0
 void Ex13()
 {
     Given("ThenStep that has an assertion without Exception that returns true", () =>
     {
         Step           = FixtureSteps.CreateThenStep(() => true);
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Pending, Step);
     });
     Given("a result of GivenStep that has Passed status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Pending status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Pending().Build()));
     When("the given ThenStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
示例#29
0
 void Ex05()
 {
     Given("ExpectStep that has an assertion that returns true", () =>
     {
         Step           = FixtureSteps.CreateExpectStep(() => true);
         ExpectedResult = FixtureStepResultAssertion.ForNullException(FixtureStepStatus.Ready, Step);
     });
     Given("a result of GivenStep that does not have Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateGivenStep()).Passed().Build()));
     Given("a result of WhenStep that has Ready status", () => StepResults.Add(FixtureStepResult.Of(FixtureSteps.CreateWhenStep()).Ready().Build()));
     When("the given ExpectStep is run", () => Result = RunnerOf(Step).Run(StepResults).Build());
     Then($"the result should be as follows:{ExpectedResult.ToDescription()}", () => FixtureStepResultAssertion.Of(Result) == ExpectedResult);
 }
示例#30
0
        public StepResults Compile(string revision, string configFile)
        {
            this.revision = revision;

            Stopwatch sw = new Stopwatch();

            sw.Start();

            StepResults sr = new StepResults();

            sr.Command = "monocompiler";

            // Create a log file


            try {
                // Load the configuration file
                XmlDocument doc = new XmlDocument();
                doc.Load(configFile);

                queue = new SerialWorkQueue(doc);

                List <Thread> threads = new List <Thread> ();

                for (int i = 0; i < 1; i++)
                {
                    Thread t = new Thread(new ThreadStart(WorkerThread));
                    threads.Add(t);
                    t.Start();
                }

                foreach (Thread t in threads)
                {
                    t.Join();
                }

                // Report results
                sr.ExitCode = 0;
                sb.AppendLine("Done");
            } catch (Exception ex) {
                //Console.WriteLine (ex.ToString ());
                sr.ExitCode = 1;
                sb.AppendFormat("MonoCompiler Error:\n{0}\n", ex.ToString());
            }

            sw.Stop();
            //Console.WriteLine (sw.Elapsed);
            sr.ExecutionTime = sw.Elapsed;
            sr.Log           = sb.ToString();

            return(sr);
        }
示例#31
0
        public void capture_error_on_the_second_frame()
        {
            var errors = new StepResults();

            errors.MoveFrame();
            errors.CaptureException("anything");

            errors.MoveFirst();
            errors.HasErrors().ShouldBeFalse();

            errors.MoveFrame();
            errors.HasErrors().ShouldBeTrue();
        }
示例#32
0
        private void UpdateStepResults(ScenarioResult result)
        {
            var actionStepResults = StepResults.ToArray();

            var idx = 0;

            foreach (var stepResult in result.StepResults)
            {
                var step = actionStepResults[idx++];
                MergeStepResult(stepResult, step);
                MergeResult(stepResult);
            }
        }
示例#33
0
        public void collapse_is_idempotent()
        {
            var result = new StepResults();
            result.MoveFrame();
            result.MoveFrame();
            result.MoveFrame();
            result.CaptureException("bad");

            result.Collapse();
            result.Collapse();
            result.Collapse();

            result.ExceptionText.ShouldEqual("bad");
        }
示例#34
0
        public void clear_will_clear_out_the_frame_errors()
        {
            var errors = new StepResults();
            errors.MoveFrame();
            errors.MoveFrame();
            errors.CaptureException("anything");

            errors.Clear();

            errors.MoveFirst();
            errors.MoveFrame();
            errors.MoveFrame();
            errors.HasErrors().ShouldBeFalse();
        }
示例#35
0
        public override void AddActionStepResult(StepResult stepResult)
        {
            MergeResult(stepResult);
            var step = StepResults.FirstOrDefault(s => s.StringStep == stepResult.StringStep);

            if (step == null)
            {
                base.AddActionStepResult(stepResult);
            }
            else
            {
                MergeStepResult(stepResult, step);
            }
        }
示例#36
0
        public void SetUp()
        {
            sentence = Sentence.For("{name} is {age}", Cell.For <string>("name"), Cell.For <int>("age"));
            step     = new Step().With("name:Max,age:6");
            tag      = new SentenceTag(sentence, step);

            context = new TestContext();
            StepResults results = context.ResultsFor(step);

            results.CaptureException("bad stuff");
            results.ExceptionText.ShouldEqual("bad stuff");


            tag.WriteResults(context);
        }
示例#37
0
        public void collapse_is_idempotent()
        {
            var result = new StepResults();

            result.MoveFrame();
            result.MoveFrame();
            result.MoveFrame();
            result.CaptureException("bad");

            result.Collapse();
            result.Collapse();
            result.Collapse();

            result.ExceptionText.ShouldEqual("bad");
        }
示例#38
0
        public StepResult(Type stepType, StepResults result)
        {
            if (stepType == null)
            {
                throw new ArgumentNullException("stepType", "Step type not specified.");
            }

            if (!TypeUtils.IsSubclassOf(stepType, typeof(AMainStrategyStepBase)))
            {
                throw new ArgumentOutOfRangeException("stepType", "Step type is not inherited from base step type.");
            }

            StepType = stepType.FullName;
            Result   = result;
        }         // constructor
        public void SetUp()
        {
            grammar =
                Fixture.VerifyStringList(() => { throw new NotImplementedException(); }).Titled(
                    "The list of strings should be").LeafNameIs("row").Grammar();

            step = new Step("anything").WithChildren("row", new Step(), new Step(), new Step());

            var context = new TestContext();

            grammar.Execute(step, context);
            counts = context.Counts;

            rowResults = context.ResultsFor(step).GetResult<IList<SetRow>>(grammar.LeafName);
            stepResults = context.ResultsFor(step);
        }
示例#40
0
        public void collapse_with_a_hierarchy()
        {
            var result = new StepResults();
            result.MoveFrame();
            result.MoveFrame();
            result.MoveFrame();
            result.CaptureException("bad");
            result.MoveFrame();
            result.MoveFrame();
            result.CaptureException("worse");

            result.Collapse();

            result.HasErrors().ShouldBeTrue();
            result.ExceptionText.ShouldContain("bad");
            result.ExceptionText.ShouldContain("worse");
        }
示例#41
0
        public StepResults Compile(string revision, string configFile)
        {
            this.revision = revision;

            Stopwatch sw = new Stopwatch ();
            sw.Start ();

            StepResults sr = new StepResults ();
            sr.Command = "monocompiler";

            // Create a log file

            try {
                // Load the configuration file
                XmlDocument doc = new XmlDocument ();
                doc.Load (configFile);

                queue = new SerialWorkQueue (doc);

                List<Thread> threads = new List<Thread> ();

                for (int i = 0; i < 1; i++) {
                    Thread t = new Thread (new ThreadStart (WorkerThread));
                    threads.Add (t);
                    t.Start ();
                }

                foreach (Thread t in threads)
                    t.Join ();

                // Report results
                sr.ExitCode = 0;
                sb.AppendLine ("Done");
            } catch (Exception ex) {
                //Console.WriteLine (ex.ToString ());
                sr.ExitCode = 1;
                sb.AppendFormat ("MonoCompiler Error:\n{0}\n", ex.ToString ());
            }

            sw.Stop ();
            //Console.WriteLine (sw.Elapsed);
            sr.ExecutionTime = sw.Elapsed;
            sr.Log = sb.ToString ();

            return sr;
        }
示例#42
0
 public Results(SentenceTag tag, ITestContext context)
 {
     _tag = tag;
     _context = context;
     _results = _context.ResultsFor(tag._step);
     _step = tag._step;
 }
示例#43
0
        public void mark_as_exception()
        {
            var errors = new StepResults();
            errors.MarkFormatFailure("key1");
            errors.MarkMissingValue("key2");

            errors.IsInException("key1").ShouldBeTrue();
            errors.IsInException("key2").ShouldBeTrue();
            errors.IsInException("key3").ShouldBeFalse();
        }
示例#44
0
        public void mark_as_failure()
        {
            var errors = new StepResults();
            errors.MarkFailure("key1");

            errors.IsFailure("key1").ShouldBeTrue();
            errors.IsFailure("key2").ShouldBeFalse();
        }
示例#45
0
        void ITestStream.StartParagraph(Paragraph paragraph, IStep step)
        {
            _paragraphResults = _context.ResultsFor(step);
            _paragraphResults.MoveFirst();

            var tag = new ParagraphTag(paragraph, step);
            _document.Push(tag);
        }
示例#46
0
        public void marking_a_missing_value_should_set_HasErrors_to_true()
        {
            var errors = new StepResults();
            errors.HasErrors().ShouldBeFalse();

            errors.MarkMissingValue("a");

            errors.HasErrors().ShouldBeTrue();
        }
示例#47
0
        public void MarkMissingStep()
        {
            var errors = new StepResults();
            errors.MarkMissingValue("a");

            errors.ExceptionText.ShouldEqual("\"a\" is not defined.");

            errors.MarkMissingValue("b");
            errors.ExceptionText.ShouldEqual("\"a\" is not defined.\n\"b\" is not defined.");
        }
示例#48
0
        public void SetUp()
        {
            cell = Cell.For<string>("name");
            cell.IsResult = true;
            step = new Step().With("name:Jeremy");

            result = new StepResults();
            //result.SetActual("name", "Chad");
            result.MarkFailure("name");

            tag = new CellTag(cell, step);
            tag.WriteResults(result, new TestContext());
        }
示例#49
0
        public void SetUp()
        {
            step = new Step("a").With("key1", "abc");
            cell = new Cell("key1", typeof (int));

            var context = new TestContext();
            cell.ReadArgument(context, step, x => Assert.Fail("should not have called me"));

            counts = context.Counts;
            results = context.ResultsFor(step);
        }
示例#50
0
        public void reset_clears_failure_keys()
        {
            var errors = new StepResults();
            errors.MarkFailure("key1");

            errors.Clear();

            errors.IsInException("key1").ShouldBeFalse();
        }
示例#51
0
        public void reset_clears_exception_text_and_has_errors()
        {
            var errors = new StepResults();
            errors.MarkMissingValue("a");
            errors.Clear();

            errors.HasErrors().ShouldBeFalse();
            errors.ExceptionText.ShouldBeEmpty();

            errors.CaptureException(new NotImplementedException().ToString());

            errors.Clear();

            errors.HasErrors().ShouldBeFalse();
            errors.ExceptionText.ShouldBeEmpty();
        }