public void GivenUnitOfMeasureWhenGetDomainIdThenDomainId() { _unitOfMeasure.domainID = "Branch"; var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension); Assert.AreEqual("Branch", unitOfMeasure.DomainID); }
public void GivenUnitOfMeasureWhenGetUomIdThenUomId() { _unitOfMeasure.uomID = 5; var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension); Assert.AreEqual(5, unitOfMeasure.UomId); }
public void GivenUnitOfMeasureWhenGetScaleThenScale() { _unitOfMeasure.scale = 783681; var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension); Assert.AreEqual(783681, unitOfMeasure.Scale); }
public void GivenUnitOfMeasureWhenGetBaseOffsetThenBaseOffset() { _unitOfMeasure.baseOffset = 5.516; var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension); Assert.AreEqual(5.516, unitOfMeasure.BaseOffset); }
public void GivenUnitOfMeasureWhenGetPluralThenPluralForCultureIsFound() { _unitOfMeasure.Name = new[] { new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasureName { locale = "de", plural = "Ursprünge" }, new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasureName { locale = CultureInfoDefault.DefaultCulture, plural = "Origins" } }; var culture = CultureInfo.GetCultureInfo("de"); var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension, culture); Assert.AreEqual("Ursprünge", unitOfMeasure.LabelPlural); }
public void GivenUnitOfMeasureWhenGetLabelThenLabelForCultureIsFound() { _unitOfMeasure.Name = new[] { new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasureName { locale = "de", label = "Herkunft" }, new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasureName { locale = CultureInfoDefault.DefaultCulture, label = "Origin" } }; var culture = CultureInfo.GetCultureInfo("de"); var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension, culture); Assert.AreEqual("Herkunft", unitOfMeasure.Label); }
protected double CombineComponentsOfSameType(UnitOfMeasureComponent component, Dictionary<string, UnitOfMeasureComponent> unitOfMeasureComponents, double finalValue, ScalarUnitOfMeasure scalarUnit) { var existingComponent = unitOfMeasureComponents[scalarUnit.UnitDimension.DomainID]; var convertedValue = _converter.Convert(component.Unit, existingComponent.Unit, 1); var newPower = existingComponent.Power + component.Power; if (newPower == 0) { var testPower = Math.Abs(existingComponent.Power) - 1; for (var i = testPower; i > 1; --i) { convertedValue = _converter.Convert(component.Unit, existingComponent.Unit, convertedValue); } unitOfMeasureComponents.Remove(scalarUnit.UnitDimension.DomainID); } else { unitOfMeasureComponents[scalarUnit.UnitDimension.DomainID] = new UnitOfMeasureComponent(existingComponent.Unit, newPower); } finalValue = component.Power < 0 ? finalValue / convertedValue : finalValue * convertedValue; return finalValue; }
public void GivenUnitDimensionWhenGetUnitDimensionThenUnitDimension() { var unitOfMeasure = new ScalarUnitOfMeasure(_unitOfMeasure, _unitDimension); Assert.AreSame(_unitDimension, unitOfMeasure.UnitDimension); }
protected double CombineComponentsOfSameType(UnitOfMeasureComponent component, Dictionary <string, UnitOfMeasureComponent> unitOfMeasureComponents, double finalValue, ScalarUnitOfMeasure scalarUnit) { var existingComponent = unitOfMeasureComponents[scalarUnit.UnitDimension.DomainID]; var convertedValue = _converter.Convert(component.Unit, existingComponent.Unit, 1); var newPower = existingComponent.Power + component.Power; if (newPower == 0) { var testPower = Math.Abs(existingComponent.Power) - 1; for (var i = testPower; i > 1; --i) { convertedValue = _converter.Convert(component.Unit, existingComponent.Unit, convertedValue); } unitOfMeasureComponents.Remove(scalarUnit.UnitDimension.DomainID); } else { unitOfMeasureComponents[scalarUnit.UnitDimension.DomainID] = new UnitOfMeasureComponent(existingComponent.Unit, newPower); } finalValue = component.Power < 0 ? finalValue / convertedValue : finalValue * convertedValue; return(finalValue); }