Example #1
0
        public ApiCostsFilterTests()
        {
            actionContext =
                new ActionExecutingContext(
                    new ActionContext(httpContext, new RouteData(),
                                      new ActionDescriptor()),
                    new List <IFilterMetadata>(), new Dictionary <string, object>(), null);

            A.CallTo(() => appPlansProvider.GetPlan(null))
            .Returns(appPlan);

            A.CallTo(() => appPlansProvider.GetPlanForApp(appEntity))
            .Returns((appPlan, "free"));

            A.CallTo(() => appPlan.BlockingApiCalls)
            .ReturnsLazily(x => apiCallsBlocking);

            A.CallTo(() => usageTracker.GetMonthCostsAsync(A <string> ._, DateTime.Today))
            .ReturnsLazily(x => Task.FromResult(apiCallsCurrent));

            next = () =>
            {
                isNextCalled = true;

                return(Task.FromResult <ActionExecutedContext?>(null));
            };

            sut = new ApiCostsFilter(appPlansProvider, usageTracker);
        }
Example #2
0
        public ApiCostsFilterTests()
        {
            actionContext =
                new ActionExecutingContext(
                    new ActionContext(httpContext, new RouteData(),
                                      new ActionDescriptor()),
                    new List <IFilterMetadata>(), new Dictionary <string, object>(), null !);

            next = () =>
            {
                isNextCalled = true;

                return(Task.FromResult <ActionExecutedContext>(null !));
            };

            sut = new ApiCostsFilter(usageGate);
        }