Exemplo n.º 1
0
        public void ConfigurationValidatedWhileUsingDefaultOptions()
        {
            // Given
            var configuration = new RequestRateLimiterConfiguration();

            // When configuration is validated
            var exception = Record.Exception(() => configuration.Validate());

            // Then it should successfully validate
            exception.Should().BeNull();
        }
Exemplo n.º 2
0
        public void ConfigurationValidatedWithBurstingSetToZero()
        {
            // Given
            var configuration = new RequestRateLimiterConfiguration
            {
                Bursting = 0
            };

            // When configuration is validated
            var exception = Record.Exception(() => configuration.Validate());

            // Then it should throw ArgumentOutOfRangeException
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentOutOfRangeException>();
            exception.Message.Should().Contain("Bursting must be greater than 0.");
            ((ArgumentOutOfRangeException)exception).ParamName.Should().Be("Bursting");
        }
Exemplo n.º 3
0
        public void ConfigurationValidatedWithKeysPrefixSetToNull()
        {
            // Given
            var configuration = new RequestRateLimiterConfiguration
            {
                KeysPrefix = null
            };

            // When configuration is validated
            var exception = Record.Exception(() => configuration.Validate());

            // Then it should throw ArgumentNullException
            exception.Should().NotBeNull();
            exception.Should().BeOfType <ArgumentNullException>();
            exception.Message.Should().Contain("Keys prefix must be provided.");
            ((ArgumentNullException)exception).ParamName.Should().Be("KeysPrefix");
        }