Exemple #1
0
        public void GetMinimumOperations_UsesDefaultValueIfNoSpecificValueConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyPositiveInt;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    MinimumOperations = expectedConfigValue
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetMinimumOperations(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }
Exemple #2
0
        public void GetMinimumOperations_UsesDefaultValueIfNoSpecificValueOrDefaultValueConfigured_DefaultIs10()
        {
            // Arrange

            const long expectedDefaultMinimumOperations = 10;

            var       groupKey            = AnyGroupKey;
            const int expectedConfigValue = 10;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    MinimumOperations = expectedConfigValue
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetMinimumOperations(groupKey);

            // Assert

            Assert.Equal(expectedDefaultMinimumOperations, value);
        }
Exemple #3
0
        public void GetMinimumOperations_UsesSpecificValueIfConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyPositiveInt;

            var mockConfig = new MjolnirConfiguration
            {
                BreakerConfigurations = new Dictionary <string, BreakerConfiguration>
                {
                    {
                        groupKey.Name,
                        new BreakerConfiguration
                        {
                            MinimumOperations = expectedConfigValue
                        }
                    }
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetMinimumOperations(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }