public void UpdateShouldCalculateCorrectAverageTwoValues() { var host = new AverageCalc(); host.Update(456); host.Update(195); Assert.That(host.Average, Is.EqualTo(325.5), "Incorrect Average Calculation for a two updates"); }
public void UpdateShouldCalculateCorrectAverageSingleValue() { var host = new AverageCalc(); host.Update(456); Assert.That(host.Average, Is.EqualTo(456), "Incorrect Average Calculation for a single update"); }
public void UpdateShouldCalculateCorrectAverageTenValues() { var host = new AverageCalc(); for (var i = 1; i <= 10; i++) { host.Update(i); } Assert.That(host.Average, Is.EqualTo(5.5), "Incorrect Average Calculation for a two updates"); }
private static void UpdateWithRandoms(AverageCalc host, int numberOfElements, int maxRange) { double sum = 0; for (var i = 0; i < numberOfElements; i++) { var val = GetRandomNumber(0, maxRange); host.Update(val); sum += val; } var actual = sum / numberOfElements; Assert.That(host.Average, Is.EqualTo(actual), "Incorrect Average Calculation"); }