Пример #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);
        }
Пример #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);
        }
Пример #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);
        }