コード例 #1
0
        public void apply_simple_check_no_failures()
        {
            var records = new PerfRecord[]
            {
                new PerfRecord("Grammar", "One", 0, 0),
                new PerfRecord("Grammar", "Two", 0, 0),
                new PerfRecord("Grammar", "Three", 0, 0),
                new PerfRecord("Request", "One", 0, 0),
                new PerfRecord("Request", "Two", 0, 0),
                new PerfRecord("Request", "Three", 0, 0),
                new PerfRecord("Request", "One", 0, 0),
                new PerfRecord("Request", "Two", 0, 0),
            };

            PerformancePolicies.PerfLimit(25, r => r.Subject == "One");

            records[2].MarkEnd(10);
            records[3].MarkEnd(10);

            var context = SpecContext.Basic();

            PerformancePolicies.Apply(context, records);

            records.Any(x => x.PerfViolation).ShouldBeFalse();

            context.Counts.Exceptions.ShouldBe(0);
        }
コード例 #2
0
        public void apply_simple_check()
        {
            var records = new PerfRecord[]
            {
                new PerfRecord("Grammar", "One", 0, 0),
                new PerfRecord("Grammar", "Two", 0, 0),
                new PerfRecord("Grammar", "Three", 0, 0),
                new PerfRecord("Request", "One", 0, 0),
                new PerfRecord("Request", "Two", 0, 0),
                new PerfRecord("Request", "Three", 0, 0),
                new PerfRecord("Request", "One", 0, 0),
                new PerfRecord("Request", "Two", 0, 0),
            };

            PerformancePolicies.PerfLimit(25, r => r.Subject == "One");

            records[2].MarkEnd(10);
            records[3].MarkEnd(50);

            var context = SpecContext.Basic();

            PerformancePolicies.Apply(context, records);

            records.Where(x => x.PerfViolation).ShouldHaveTheSameElementsAs(records[3]);

            context.Counts.Exceptions.ShouldBe(1);
        }
コード例 #3
0
        public void every_extension_and_the_inner_system_are_called_on_after_extension()
        {
            var specContext = SpecContext.Basic();

            var execution = theSystem.CreateContext();

            execution.AfterExecution(specContext);

            theInnerSystem.LastAfterEach.ShouldBeTheSameAs(specContext);
            theInnerSystem.Extension1.LastAfterEach.ShouldBeTheSameAs(specContext);
            theInnerSystem.Extension2.LastAfterEach.ShouldBeTheSameAs(specContext);
        }
コード例 #4
0
        public void every_extension_and_the_inner_system_on_before_execution()
        {
            var specContext = SpecContext.Basic();

            var execution = theSystem.CreateContext();

            execution.BeforeExecution(specContext);

            theInnerSystem.LastBeforeEach.ShouldBeTheSameAs(specContext);
            theInnerSystem.Extension1.LastBeforeEach.ShouldBeTheSameAs(specContext);
            theInnerSystem.Extension2.LastBeforeEach.ShouldBeTheSameAs(specContext);
        }
コード例 #5
0
        public void execute()
        {
            var grammar = ActionMethodGrammar.Create(x => x.Go(null, 0, 0), theTarget);

            grammar.Compile(new Fixture(), CellHandling.Basic()).ShouldBeOfType <Sentence>();

            var values = new StepValues("id");

            values.Store("name", "Jeremy");
            values.Store("age", 41);
            values.Store("percentAwake", 50.1);

            ShouldBeTestExtensions.ShouldBe(grammar.Execute(values, SpecContext.Basic()).Any(), false);

            theTarget.Name.ShouldBe("Jeremy");
            theTarget.Age.ShouldBe(41);
            theTarget.PercentAwake.ShouldBe(50.1);
        }