Ejemplo n.º 1
0
        public void GetVolumeTest()
        {
            foreach (UnitGroup testUnits in new List <UnitGroup>()
            {
                units_ft_yd, units_m_m
            })
            {
                // Raw values that will be converted to a GCD area and volume and then back to double to ensure we get the same values
                double cellAreaVal  = 2.2500099687832296;
                double areaOriginal = 41626748.17941805;
                double volOriginal  = 91729.489667072165;

                // Deserialize from String
                Area          cellArea = Area.From(cellAreaVal, testUnits.ArUnit);
                Area          area     = Area.From(areaOriginal, testUnits.ArUnit);
                Volume        vol      = Volume.From(volOriginal, testUnits.VolUnit);
                GCDAreaVolume areaVol  = new GCDAreaVolume(area, vol, cellArea, testUnits);

                // Serialize back to string
                double areaResult = areaVol.GetArea(cellArea).As(testUnits.ArUnit);
                double volResult  = areaVol.GetVolume(cellArea, testUnits).As(testUnits.VolUnit);

                Assert.AreEqual(areaOriginal, areaResult, 0.00001);
                Assert.AreEqual(volOriginal, volResult, 0.00001);
            }
        }
Ejemplo n.º 2
0
 private static void SerializeAreaVolume(XmlDocument xmlDoc, XmlNode nodParent, GCDAreaVolume areaVol, UnitGroup units, UnitsNet.Area cellArea)
 {
     nodParent.AppendChild(xmlDoc.CreateElement("Area")).InnerText   = areaVol.GetArea(cellArea).As(units.ArUnit).ToString("R");
     nodParent.AppendChild(xmlDoc.CreateElement("Volume")).InnerText = areaVol.GetVolume(cellArea, units.VertUnit).As(units.VolUnit).ToString("R");
 }