public bool ValidateRule(HealthCount healthCount) { if ((healthCount.Failures / (decimal)healthCount.Total) > _failureThreshold) { return(true); } return(false); }
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); }
public void Subscribe(LevelManager levelManager, HealthCount healthCount) { levelManager.AllBricksDestroyed += GameFinish; healthCount.OutOfHealth += GameFinish; }
private void RetrieveCurrentHealthCount() { _healthCount = _healthCountService.GetCurrentHealthCount(_keys); }
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"); }