Exemplo n.º 1
0
        public UsageGateTests()
        {
            appEntity = Mocks.App(appId);

            A.CallTo(() => grainFactory.GetGrain <IUsageNotifierGrain>(SingleGrain.Id, null))
            .Returns(usageNotifierGrain);

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

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

            A.CallTo(() => appPlan.MaxApiCalls)
            .ReturnsLazily(x => apiCallsMax);

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

            A.CallTo(() => usageTracker.GetMonthCallsAsync(appId.Id.ToString(), today, A <string> ._))
            .ReturnsLazily(x => Task.FromResult(apiCallsCurrent));

            sut = new UsageGate(appPlansProvider, usageTracker, grainFactory);
        }