Ejemplo n.º 1
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.º 2
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.º 3
0
        public void GetSnapshotTtlMillis_UsesDefaultValueIfNoSpecificValueOrDefaultValueConfigured_DefaultIs1000()
        {
            // Arrange

            const long expectedDefaultSnapshotTtlMillis = 1000;

            var groupKey = AnyGroupKey;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    SnapshotTtlMillis = expectedDefaultSnapshotTtlMillis
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetSnapshotTtlMillis(groupKey);

            // Assert

            Assert.Equal(expectedDefaultSnapshotTtlMillis, value);
        }
Ejemplo n.º 4
0
        public void GetSnapshotTtlMillis_UsesSpecificValueIfConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyPositiveInt;

            var mockConfig = new MjolnirConfiguration
            {
                BreakerConfigurations = new Dictionary <string, BreakerConfiguration>
                {
                    {
                        groupKey.Name,
                        new BreakerConfiguration
                        {
                            SnapshotTtlMillis = expectedConfigValue
                        }
                    }
                }
            };
            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetSnapshotTtlMillis(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }
Ejemplo n.º 5
0
        public void GetForceFixed_UsesDefaultValueIfNoSpecificValueOrDefaultValueConfigured_DefaultIsFalse()
        {
            // Arrange

            const bool expectedDefaultForceFixed = false;

            var groupKey = AnyGroupKey;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    ForceFixed = expectedDefaultForceFixed
                }
            };
            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetForceFixed(groupKey);

            // Assert

            Assert.Equal(expectedDefaultForceFixed, value);
        }
Ejemplo n.º 6
0
        public void GetForceFixed_UsesSpecificValueIfConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyBool;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetForceFixed(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }
Ejemplo n.º 7
0
        public void GetForceTripped_UsesDefaultValueIfNoSpecificValueConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyBool;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetForceTripped(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }
Ejemplo n.º 8
0
        public void GetThresholdPercentage_UsesDefaultValueIfNoSpecificValueOrDefaultValueConfigured_DefaultIs50()
        {
            // Arrange

            const int expectedDefaultThresholdPercentage = 50;

            var groupKey = AnyGroupKey;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    ThresholdPercentage = expectedDefaultThresholdPercentage
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetThresholdPercentage(groupKey);

            // Assert

            Assert.Equal(expectedDefaultThresholdPercentage, value);
        }