public void Given1Literand1000Ml_ForCompare_shouldReturnTrue() { VolumeQuantity milileterObject = new VolumeQuantity("ml", 1000); VolumeQuantity literObject = new VolumeQuantity("liter", 1); Assert.IsTrue(this.compare.CompareVolume(milileterObject, literObject)); } //// end : public void Given1Literand1000Ml_ForCompare_shouldReturnTrue()
public void GivenGallonAndLitre_ForSum_shouldReturnSumInLitre() { VolumeQuantity gallonObject = new VolumeQuantity("gallon", 1); VolumeQuantity literObject = new VolumeQuantity("liter", 3.78); Assert.AreEqual(7.57, Math.Round(Calculate.AddToLiters(gallonObject, literObject)), 2); } //// end : public void GivenGallonAndLitre_ForSum_shouldReturnSumInLitre()
public void Given1GallonandLiter_ForCompare_shouldReturnTrue() { VolumeQuantity gallonObject = new VolumeQuantity("gallon", 1); VolumeQuantity literObject = new VolumeQuantity("liter", 3.78); Assert.IsTrue(this.compare.CompareVolume(gallonObject, literObject)); } //// end : public void Given1GallonandLiter_ForCompare_shouldReturnTrue()
} //// end : public static double AddToInch(LengthQuantity quantityOne, LengthQuantity quantityTwo) /// <summary> /// method to add two volume quantities /// </summary> /// <param name="quantityOne"> first value </param> /// <param name="quantityTwo"> second value </param> /// <returns> sum in inches </returns> public static double AddToLiters(VolumeQuantity quantityOne, VolumeQuantity quantityTwo) { try { if (quantityOne.Unit != null && quantityTwo.Unit != null) { return(((ConvertTo.ConvertVolume(quantityOne.Unit) * quantityOne.Volume) + (ConvertTo.ConvertVolume(quantityTwo.Unit) * quantityTwo.Volume)) / ConvertTo.ConvertVolume("liter")); } else { throw new ArgumentOutOfRangeException(); } } catch (Exception exception) { Console.WriteLine(exception.Message); throw; } } //// end : public static double AddToLiters(VolumeQuantity quantityOne, VolumeQuantity quantityTwo)
} //// end : public bool CompareLength(Measure quantityOne, Measure quantityTwo) /// <summary> /// method to compare two volume quantities /// </summary> /// <param name="quantityOne"> quantity one to compare </param> /// <param name="quantityTwo"> quantity two to compare </param> /// <returns> true or false </returns> public bool CompareVolume(VolumeQuantity quantityOne, VolumeQuantity quantityTwo) { return(ConvertTo.ConvertVolume(quantityOne.Unit) * quantityOne.Volume == ConvertTo.ConvertVolume(quantityTwo.Unit) * quantityTwo.Volume); } //// end : public bool CompareVolume(VolumeQuantity quantityOne, VolumeQuantity quantityTwo)