Exemplo n.º 1
0
        static void Main(string[] args)
        {
            var budgetter = new PerformanceBudgetter();

            budgetter.RunWithBudget("over-budget", 1, LongRunningTask, LogResult);
            budgetter.RunWithBudget("under-budget", 100, LongRunningTask, LogResult);

            Console.ReadLine();
        }
        public void Returns_Budget_If_Timer_Null()
        {
            var budgetter = new PerformanceBudgetter(null);
            var budget = budgetter.RunWithBudget("test", 1.0M, null);

            Assert.NotNull(budget);
        }
        public void Default_Constructor_Returns_Budget()
        {
            var budgetter = new PerformanceBudgetter();

            var budget = budgetter.RunWithBudget("test", 1.0M, null);

            Assert.NotNull(budget);
        }
        public void Returns_Budget()
        {
            var timer = new PerformanceTimerProviderFactory(new StopwatchTimerProvider());
            var budgetter = new PerformanceBudgetter(timer);

            var budget = budgetter.RunWithBudget("test", 1.0M, null);

            Assert.NotNull(budget);
        }
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            base.OnActionExecuting(filterContext);

            string url = filterContext.HttpContext.Request.Url.ToString();

            var budgetter = new PerformanceBudgetter();

            var budget = budgetter.RunWithBudget(url, budgetMs, onCompletion);

            SetPerformaceBudgetterFromContext(budget, filterContext);
        }