public void DurationConverts() { Duration L1 = new Duration(3600, DurationUnit.Second); Assert.AreEqual(3600, (double)L1.As(DurationUnit.Second), 0000000000.1); Assert.AreEqual(0.041666666666666664d, (double)L1.As(DurationUnit.Day), 0000000000.1); Assert.AreEqual(1d, (double)L1.As(DurationUnit.Hour), 0000000000.1); Assert.AreEqual(3599999999999.9995d, (double)L1.As(DurationUnit.Nanosecond), 0000000000.1); }
public void Serialize(XmlNode nodParent) { XmlNode nodMA = nodParent.AppendChild(nodParent.OwnerDocument.CreateElement("MorphologicalAnalysis")); nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Name")).InnerText = Name; nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Folder")).InnerText = ProjectManager.Project.GetRelativePath(OutputFolder.FullName); nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Porosity")).InnerText = Porosity.ToString(CultureInfo.InvariantCulture); nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Density")).InnerText = Density.ToString(CultureInfo.InvariantCulture); nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Competency")).InnerText = Competency.ToString(CultureInfo.InvariantCulture); nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Spreadsheet")).InnerText = ProjectManager.Project.GetRelativePath(Spreadsheet); XmlNode nodDuration = nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("Duration")); nodDuration.InnerText = Duration.As(DisplayUnits_Duration).ToString("R", CultureInfo.InvariantCulture); nodDuration.Attributes.Append(nodParent.OwnerDocument.CreateAttribute("units")).InnerText = DisplayUnits_Duration.ToString(); XmlNode nodMinFluxCell = nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("MinimumFluxUnit")); if (BoundaryFluxUnit != null) { nodMinFluxCell.InnerText = BoundaryFluxUnit.Name; } XmlNode nodMinFlux = nodMA.AppendChild(nodParent.OwnerDocument.CreateElement("MinimumFluxVolume")); nodMinFlux.InnerText = BoundaryFlux.As(ProjectManager.Project.Units.VolUnit).ToString("R", CultureInfo.InvariantCulture); }
public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { var quantity = new Duration(value: 1, unit: Duration.BaseUnit); Func <object> AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) { var value = (double)AsWithSIUnitSystem(); Assert.Equal(1, value); } else { Assert.Throws <ArgumentException>(AsWithSIUnitSystem); } }