Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }