public void FinalGravityCalculation_Passes() { ICalculateFinalGravityFactory finalGravityFactory = new CalculateFinalGravityFactory(); ICalculateFinalGravity finalGravityCalculator = finalGravityFactory.GetCalculator(new FinalGravityStrategy()); finalGravityCalculator.StartingVolume = 5; finalGravityCalculator.FinalVolume = 4.5; finalGravityCalculator.OriginalGravity = 1.05; var finalGravity = finalGravityCalculator.Calculate(); Assert.AreEqual(1.05556, Math.Round(finalGravity, 5)); }
public double CalculateFinalGravity(ICalculateFinalGravity finalGravityDetails) { if (finalGravityDetails.FinalVolume <= 0) { throw new ArgumentOutOfRangeException("FinalVolume", "Final Volume must be greater than zero"); } if (finalGravityDetails.StartingVolume <= 0) { throw new ArgumentOutOfRangeException("StartingVolume", "Starting Volume must be greater than zero"); } var finalGravity = 1 + (finalGravityDetails.StartingVolume * (System.Math.Abs(1 - finalGravityDetails.OriginalGravity) * 1000) / finalGravityDetails.FinalVolume / 1000); return(finalGravity); }