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

            const bool expectedDefaultForceTripped = false;

            var groupKey = AnyGroupKey;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetForceTripped(groupKey);

            // Assert

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

            var groupKey            = AnyGroupKey;
            var expectedConfigValue = AnyBool;

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

            var config = new FailurePercentageCircuitBreakerConfig(mockConfig);

            // Act

            var value = config.GetForceTripped(groupKey);

            // Assert

            Assert.Equal(expectedConfigValue, value);
        }