public LimitProviderBaseTests()
        {
            keyGenerator = A.Fake<ILimitKeyGenerator>();
            appSetting = A.Fake<IAppSettings>();

            limitProvider = new LimitProviderBase(keyGenerator, appSetting);
        }
Exemple #2
0
        public LimitProviderBaseTests()
        {
            keyGenerator = A.Fake <ILimitKeyGenerator>();
            appSetting   = A.Fake <IAppSettings>();

            limitProvider = new LimitProviderBase(keyGenerator, appSetting);
        }
Exemple #3
0
        public AppSettingsLimitProvider(ILimitKeyGenerator keyGenerator, IAppSettings appSettings)
        {
            keyGenerator.ThrowIfNull(nameof(keyGenerator));
            appSettings.ThrowIfNull(nameof(appSettings));

            this.keyGenerator = keyGenerator;
            this.appSettings  = appSettings;
        }
        public RateLimitFeatureTests()
        {
            redisManager = A.Fake<IRedisClientsManager>();
            limitProvider = A.Fake<ILimitProvider>();
            keyGenerator = A.Fake<ILimitKeyGenerator>();

            var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization());
            limit = fixture.Create<Limits>();
            A.CallTo(() => limitProvider.GetLimits(A<IRequest>.Ignored)).Returns(limit);
        }
Exemple #5
0
        public RateLimitFeatureTests()
        {
            redisManager  = A.Fake <IRedisClientsManager>();
            limitProvider = A.Fake <ILimitProvider>();
            keyGenerator  = A.Fake <ILimitKeyGenerator>();

            var fixture = new Fixture().Customize(new AutoFakeItEasyCustomization());

            limit = fixture.Create <Limits>();
            A.CallTo(() => limitProvider.GetLimits(A <IRequest> .Ignored)).Returns(limit);
        }
Exemple #6
0
        private void EnsureDependencies(IAppHost appHost)
        {
            if (KeyGenerator == null)
            {
                KeyGenerator = new LimitKeyGenerator();
            }

            if (LimitProvider == null)
            {
                LimitProvider = new AppSettingsLimitProvider(KeyGenerator, appHost.AppSettings);
            }
        }
        public LimitProviderBase(ILimitKeyGenerator keyGenerator, IAppSettings appSettings)
        {
            keyGenerator.ThrowIfNull(nameof(keyGenerator));
            appSettings.ThrowIfNull(nameof(appSettings));

            this.keyGenerator = keyGenerator;
            this.appSettings = appSettings;

            // This is purely to ensure that we always have a default limit
            defaultLimits = new LimitGroup
            {
                Limits = new List<LimitPerSecond>
                {
                    new LimitPerSecond { Seconds = 60, Limit = DefaultPerMinute },
                    new LimitPerSecond { Seconds = 3600, Limit = DefaultPerHour }
                }
            };
        }
Exemple #8
0
        public LimitProviderBase(ILimitKeyGenerator keyGenerator, IAppSettings appSettings)
        {
            keyGenerator.ThrowIfNull(nameof(keyGenerator));
            appSettings.ThrowIfNull(nameof(appSettings));

            this.keyGenerator = keyGenerator;
            this.appSettings  = appSettings;

            // This is purely to ensure that we always have a default limit
            defaultLimits = new LimitGroup
            {
                Limits = new List <LimitPerSecond>
                {
                    new LimitPerSecond {
                        Seconds = 60, Limit = DefaultPerMinute
                    },
                    new LimitPerSecond {
                        Seconds = 3600, Limit = DefaultPerHour
                    }
                }
            };
        }
        private void EnsureDependencies(IAppHost appHost)
        {           
            if (KeyGenerator == null)
                KeyGenerator = new LimitKeyGenerator();

            if (LimitProvider == null)
                LimitProvider = new LimitProviderBase(KeyGenerator, appHost.AppSettings);
        }