public void only_cache_up_to_the_setting_limit()
        {
            var settings = new DiagnosticsSettings{
                MaxRequests = 10
            };

            var cache = new RequestHistoryCache(settings);

            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());

            cache.RecentReports().Count().ShouldEqual(9);

            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());
            cache.Store(new RequestLog());

            cache.RecentReports().Count().ShouldEqual(settings.MaxRequests);
        }
        public void if_disabled_just_return_inner_app_func()
        {
            Func<IDictionary<string, object>, Task> inner = d => Task.Factory.StartNew(() => { });

            var settings = new DiagnosticsSettings {TraceLevel = TraceLevel.None};
            settings.WrapAppFunc(null, inner).ShouldBeSameAs(inner);
        }
        public void only_cache_up_to_the_setting_limit()
        {
            var settings = new DiagnosticsSettings
            {
                MaxRequests = 10
            };

            var cache = new ChainExecutionHistory(settings);

            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());

            cache.RecentReports().Count().ShouldBe(9);

            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());
            cache.Store(new ChainExecutionLog());

            cache.RecentReports().Count().ShouldBe(settings.MaxRequests);
        }
        public void add_role()
        {
            var settings = new DiagnosticsSettings();
            settings.RestrictToRule("admin");

            settings.AuthorizationRights.Single().ShouldBeOfType<AllowRole>()
                .Role.ShouldEqual("admin");
        }
        public void can_override()
        {
            var settings = new DiagnosticsSettings();
            settings.SetIfNone(TraceLevel.Verbose);

            settings.TraceLevel.ShouldEqual(TraceLevel.Verbose);

            settings.SetIfNone(TraceLevel.Production);

            settings.TraceLevel.ShouldEqual(TraceLevel.Verbose);
        }
 public RequestHistoryCache(DiagnosticsSettings settings)
 {
     _settings = settings;
 }
 public RequestHistoryCache(IEnumerable<IRequestHistoryCacheFilter> filters, DiagnosticsSettings settings)
 {
     _filters = filters;
     _settings = settings;
 }