Example #1
0
        public void GivenUnitDimensionWhenGetDomainIdThenDomainId()
        {
            _unitDimension.domainID = "years";

            var unitDimension = new UnitDimension(_unitDimension);
            Assert.AreEqual("years", unitDimension.DomainID);
        }
Example #2
0
        public ScalarUnitOfMeasure(UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure unitOfMeasure, UnitDimension unitDimension, CultureInfo culture)
        {
            var name = GetName(unitOfMeasure.Name, culture);

            Label         = unitOfMeasure.Name != null ? name.label : null;
            LabelPlural   = unitOfMeasure.Name != null ? name.plural : null;
            DomainID      = unitOfMeasure.domainID;
            UomId         = unitOfMeasure.uomID;
            BaseOffset    = unitOfMeasure.baseOffset;
            Scale         = unitOfMeasure.scale;
            UnitDimension = unitDimension;
        }
        public ScalarUnitOfMeasure(UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure unitOfMeasure, UnitDimension unitDimension, CultureInfo culture)
        {
            var name = GetName(unitOfMeasure.Name, culture);

            Label = unitOfMeasure.Name != null ? name.label : null;
            LabelPlural = unitOfMeasure.Name != null ? name.plural : null;
            DomainID = unitOfMeasure.domainID;
            UomId = unitOfMeasure.uomID;
            BaseOffset = unitOfMeasure.baseOffset;
            Scale = unitOfMeasure.scale;
            UnitDimension = unitDimension;
        }
        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);
        }
Example #5
0
        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 Setup()
 {
     _unitDimension = new UnitDimension(new UnitSystemUnitDimension());
     _unitOfMeasure = new UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure();
 }
Example #7
0
 public ScalarUnitOfMeasure(UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure unitOfMeasure, UnitDimension unitDimension)
     : this(unitOfMeasure, unitDimension, CultureInfo.CurrentUICulture)
 {
 }
 public ScalarUnitOfMeasure(UnitSystemUnitDimensionUnitDimensionRepresentationUnitOfMeasure unitOfMeasure, UnitDimension unitDimension) 
     : this(unitOfMeasure, unitDimension, CultureInfo.CurrentUICulture)
 {
 }
Example #9
0
 public void GivenUnitDimensionWhenGetUnitsThenUnitOfMeasureCollection()
 {
     var UnitDimension = new UnitDimension(_unitDimension);
     Assert.IsInstanceOf<UnitOfMeasureCollection>(UnitDimension.Units);
 }
Example #10
0
        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);
        }
Example #11
0
        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);
        }