Ejemplo n.º 1
0
        public void GetTrippedDurationMillis_UsesDefaultValueIfNoSpecificValueConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyPositiveInt;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetTrippedDurationMillis(groupKey);

            // Assert

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

            const long expectedDefaultTrippedDurationMillis = 10000;
            var        groupKey = AnyGroupKey;

            var mockConfig = new MjolnirConfiguration
            {
                DefaultBreakerConfiguration = new BreakerConfiguration
                {
                    TrippedDurationMillis = expectedDefaultTrippedDurationMillis
                }
            };

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetTrippedDurationMillis(groupKey);

            // Assert

            Assert.Equal(expectedDefaultTrippedDurationMillis, value);
        }
Ejemplo n.º 3
0
        public void GetTrippedDurationMillis_UsesSpecificValueIfConfigured()
        {
            // Arrange

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyPositiveInt;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetTrippedDurationMillis(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }