public void ReturnFourKilometersFromFourThousandMeters() { Mock.Arrange(() => mockedDatabaseAccessor.GetBaseUnitRatioFromUnitName("kilometer")).Returns(1000); var unitAdjuster = new UnitAdjuster(mockedDatabaseAccessor); var newUnitValue = unitAdjuster.FromBaseUnitAmount(4000, "kilometer"); Assert.AreEqual(4, newUnitValue); }
public void ReturnSevenMetersWhenGivenSevenMeters() { Mock.Arrange(() => mockedDatabaseAccessor.GetBaseUnitRatioFromUnitName("meter")).Returns(1); Mock.Arrange(() => mockedUnit.Quantity).Returns(7); Mock.Arrange(() => mockedUnit.Name).Returns("meter"); var unitAdjuster = new UnitAdjuster(mockedDatabaseAccessor); var newUnitQuantity = unitAdjuster.ToBaseUnitAmount(mockedUnit); Assert.AreEqual(7, newUnitQuantity); }
public double ToBaseUnitAmount(Unit unit) { return(unit.Quantity * databaseAccessor.GetBaseUnitRatioFromUnitName(unit.Name)); }