Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public void create_policies()
        {
            // SAMPLE: PerformancePolicies
            // All grammars of any kind should run within 5 seconds
            PerformancePolicies.PerfLimit(5000, r => r.Type == "Grammar");

            // No specification should exceed 15 seconds
            PerformancePolicies.PerfLimitBySubject(15000, "Specification");

            // All grammars with "Open" in their name should run in under a second
            PerformancePolicies.PerfLimit(1000, r => r.Subject.Contains("Open"));
            // ENDSAMPLE
        }
Exemplo n.º 4
0
 public override void SetUp()
 {
     PerformancePolicies.ClearAll();
     PerformancePolicies.PerfLimit(50, r => r.Subject == "Fake");
 }
Exemplo n.º 5
0
 public PerformancePoliciesTester()
 {
     PerformancePolicies.ClearAll();
 }
Exemplo n.º 6
0
 public void RequestPerformanceThresholdIs(int milliseconds)
 {
     PerformancePolicies.PerfLimit(milliseconds, r => r.Type == HttpRequestSubject);
 }