コード例 #1
0
        public bool ValidateRule(HealthCount healthCount)
        {
            if ((healthCount.Failures / (decimal)healthCount.Total) > _failureThreshold)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
        public bool ValidateRule(HealthCount healthCount)
        {
            if (healthCount.Failures > _exceptionsAllowedBeforeBreaking)
            {
                return(true);
            }

            return(false);
        }
        public void ShouldBeTrueWhenNumberOfFailuresIsGreaterThenThreshold(decimal threshold, int failures, int successes, bool expected)
        {
            //Arrange
            var healthCount = new HealthCount()
            {
                Failures  = failures,
                Successes = successes
            };
            var sut = new ProportionFailuresRule(threshold);

            //Act
            var result = sut.ValidateRule(healthCount);

            //Assert
            Assert.Equal(expected, result);
        }
コード例 #4
0
ファイル: GameLoop.cs プロジェクト: Technet99m/BrickBreaker
 public void Subscribe(LevelManager levelManager, HealthCount healthCount)
 {
     levelManager.AllBricksDestroyed += GameFinish;
     healthCount.OutOfHealth         += GameFinish;
 }
コード例 #5
0
 private void RetrieveCurrentHealthCount()
 {
     _healthCount = _healthCountService.GetCurrentHealthCount(_keys);
 }
コード例 #6
0
        public void UpdateBasedOnHealthCount(CircuitBreakerSimulation circuitBreakerSimulation, HealthCount healthCount)
        {
            Visible = healthCount != null;

            var timeSinceStarted = DateTime.UtcNow - healthCount?.StartedAt;

            labelSuccesses.Text = healthCount?.Successes.ToString();
            labelFailures.Text  = healthCount?.Failures.ToString();

            var secondsAfterPreviousBucket = healthCount?.DifferenceFromNextHealthCount != null
                ? healthCount.DifferenceFromNextHealthCount.Value.TotalSeconds.ToString("#.##") + " s"
                : string.Empty;

            labelTimeDifference.Text = secondsAfterPreviousBucket;

            var timeLeftBeforeDropped = TimeSpan.FromSeconds(circuitBreakerSimulation.SamplingDurationSeconds) - timeSinceStarted;
            var displayTime           = timeLeftBeforeDropped != null && timeLeftBeforeDropped > TimeSpan.Zero
                ? timeLeftBeforeDropped.Value
                : TimeSpan.Zero;

            labelTime.Text = displayTime.ToString("s\\.f");
        }