public void EqualityTest_Length_Length() { var length = UnitDimension.Length; var other = new UnitDimension(q => q == UnitBaseQuantity.Length ? 1 : 0); Assert.True(length == other); }
public void GivenUnitDimensionWhenGetUnitsThenUnitsOfMeasureAreLoaded() { _unitDimension.Items = new object[] { new UnitSystemUnitDimensionUnitDimensionRepresentation { domainID = "Anything", UnitOfMeasure = new [] { new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure { domainID = "Food" }, new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure { domainID = "Water" }, new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure { domainID = "Hydrogen" } } } }; var UnitDimension = new UnitDimension(_unitDimension); Assert.AreEqual(3, UnitDimension.Units.Count); }
public void EqualityTest_Force_Force() { var length = UnitDimension.Length; var mass = UnitDimension.Mass; var time = UnitDimension.Time; var force = length * mass / (time * time); var other = new UnitDimension(q => { switch (q) { case UnitBaseQuantity.Length: return(1); case UnitBaseQuantity.Mass: return(1); case UnitBaseQuantity.Time: return(-2); default: return(0); } }); Assert.True(force == other); }
public void GivenUnitDimensionWhenGetDomainIdThenDomainId() { _unitDimension.domainID = "years"; var unitDimension = new UnitDimension(_unitDimension); Assert.AreEqual("years", unitDimension.DomainID); }
public NumericRepresentation(RepresentationSystemRepresentationsNumericRepresentation representation, CultureInfo culture) : base(representation.domainID, representation.domainTag) { var name = GetName(representation.Name, culture); Name = name != null ? name.Value : null; Description = name != null ? name.description : null; UnitDimension = FindUnitDimension(representation); _unitOfMeasureDefaults = GetDefaultUnitOfMeasures(representation.Items); _unitOfMeasurePreferences = GetUnitOfMeasurePreferences(representation.Items); }
public void BaseDimensionTest(UnitDimension unitDimension, UnitBaseQuantity unitBaseQuantity) { Assert.AreEqual(1, unitDimension.QuantityCount); foreach (var otherUnitBaseQuantity in UnitDimension.UnitBaseQuantities) { if (otherUnitBaseQuantity != unitBaseQuantity) { Assert.False(unitDimension.HasQuantity(otherUnitBaseQuantity)); } else { Assert.True(unitDimension.HasQuantity(otherUnitBaseQuantity)); } } Assert.AreEqual(1, unitDimension.GetPower(unitBaseQuantity)); }
public NumericRepresentation(RepresentationSystemRepresentationsNumericRepresentation representation, CultureInfo culture) : base(representation.domainID, representation.domainTag) { var name = GetName(representation.Name, culture); Name = name != null ? name.Value : null; Description = name != null ? name.description : null; UnitDimension = FindUnitDimension(representation); if (representation.RelatedDDI != null) { Ddi = representation.RelatedDDI[0].ddi; if (representation.RelatedDDI.Any(d => d.isDefaultRepresentationForDDI)) { IsDefaultRepresentationForDDI = true; } } _unitOfMeasureDefaults = GetDefaultUnitOfMeasures(representation.Items); _unitOfMeasurePreferences = GetUnitOfMeasurePreferences(representation.Items); }
public void GivenUnitDimensionWhenGetNameThenNameForCultureIsFound() { _unitDimension.Name = new[] { new UnitSystemUnitDimensionName { locale = CultureInfoDefault.DefaultCulture, Value = "Life" }, new UnitSystemUnitDimensionName { locale = "de", Value = "Leben" } }; var culture = CultureInfo.GetCultureInfo("de"); var unitDimension = new UnitDimension(_unitDimension, culture); Assert.AreEqual("Leben", unitDimension.Name); }
public void GivenUnitDimensionWhenGetCompositeDimensionComponentsThenCompositeDimensionComponentsAreReturned() { _unitDimension.Items = new object[] { new UnitSystemUnitDimensionCompositeUnitDimensionRepresentation { domainID = "Anything", UnitDimensionRef = new [] { new UnitSystemUnitDimensionCompositeUnitDimensionRepresentationUnitDimensionRef { UnitDimensionRef = "utMass", baseUnitOfMeasureRef = "g", power = 1 }, new UnitSystemUnitDimensionCompositeUnitDimensionRepresentationUnitDimensionRef { UnitDimensionRef = "utArea", baseUnitOfMeasureRef = "ha", power = -1 } } } }; var expected = new List <UnitDimensionComponent> { new UnitDimensionComponent("utMass", 1), new UnitDimensionComponent("utArea", -1), }; var unitDimension = new UnitDimension(_unitDimension); Assert.AreEqual(expected[0].UnitDimensionDomainId, unitDimension.CompositeDimensionComponents[0].UnitDimensionDomainId); Assert.AreEqual(expected[0].Power, unitDimension.CompositeDimensionComponents[0].Power); Assert.AreEqual(expected[1].UnitDimensionDomainId, unitDimension.CompositeDimensionComponents[1].UnitDimensionDomainId); Assert.AreEqual(expected[1].Power, unitDimension.CompositeDimensionComponents[1].Power); }
protected UnitRepresentation(string domainId, UnitDimension unitDimension) { DomainId = domainId; UnitDimension = unitDimension; }
protected UnitBaseName <S, T> GetNewUnitBaseName(string name, string symbol, float factorValue, UnitDimension dimension) => new UnitBaseName <S, T> { Name = name, Symbol = symbol, Factor = scalarNone.GetNewFromFloat(factorValue) as S, Dimension = dimension };
public UnitBaseName <S, T> CreateUnitBaseName(string name, string symbol, float factorValue, string nameSpace, UnitDimension dimension) => new UnitBaseName <S, T> { Name = name, Symbol = symbol, Factor = GetScalar(factorValue), Namespace = nameSpace, Dimension = dimension };
public void SetUp() { UnitDimension = new UnitDimension(); }
public void Setup() { _unitDimension = new UnitDimension(new UnitSystemUnitDimension()); _unitOfMeasure = new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure(); }
public UnitBaseName <S, T> CreateUnitBaseName(string name, string symbol, S factorScalar, string nameSpace, UnitDimension dimension) => new UnitBaseName <S, T> { Name = name, Symbol = symbol, Factor = factorScalar, Namespace = nameSpace, Dimension = dimension };
public void GivenUnitDimensionWhenGetUnitsThenUnitOfMeasureCollection() { var UnitDimension = new UnitDimension(_unitDimension); Assert.IsInstanceOf <UnitOfMeasureCollection>(UnitDimension.Units); }
protected UnitRepresentation(string domainId, UnitDimension unitDimension) { DomainId = domainId; UnitDimension = unitDimension; }