diff --git a/Common/UnitDefinitions/RadiationEquivalentDoseRate.json b/Common/UnitDefinitions/RadiationEquivalentDoseRate.json index 70e4541e83..e33d3bae8e 100644 --- a/Common/UnitDefinitions/RadiationEquivalentDoseRate.json +++ b/Common/UnitDefinitions/RadiationEquivalentDoseRate.json @@ -1,6 +1,6 @@ { "Name": "RadiationEquivalentDoseRate", - "BaseUnit": "SievertPerHour", + "BaseUnit": "SievertPerSecond", "XmlDocSummary": "A dose rate is quantity of radiation absorbed or delivered per unit time.", "XmlDocsRemarks": "https://en.wikipedia.org/wiki/Dose_rate", "BaseDimensions": { @@ -11,8 +11,8 @@ { "SingularName": "SievertPerHour", "PluralName": "SievertsPerHour", - "FromUnitToBaseFunc": "{x}", - "FromBaseToUnitFunc": "{x}", + "FromUnitToBaseFunc": "{x}/3600", + "FromBaseToUnitFunc": "{x}*3600", "Prefixes": [ "Nano", "Micro", "Milli" ], "Localization": [ { @@ -25,11 +25,28 @@ } ] }, + { + "SingularName": "SievertPerSecond", + "PluralName": "SievertsPerSecond", + "FromUnitToBaseFunc": "{x}", + "FromBaseToUnitFunc": "{x}", + "Prefixes": [ "Nano", "Micro", "Milli" ], + "Localization": [ + { + "Culture": "en-US", + "Abbreviations": [ "Sv/s" ] + }, + { + "Culture": "ru-RU", + "Abbreviations": [ "Зв/с" ] + } + ] + }, { "SingularName": "RoentgenEquivalentManPerHour", "PluralName": "RoentgensEquivalentManPerHour", - "FromUnitToBaseFunc": "{x} / 100", - "FromBaseToUnitFunc": "{x} * 100", + "FromUnitToBaseFunc": "{x} / 100 / 3600", + "FromBaseToUnitFunc": "{x} * 100 * 3600", "Prefixes": [ "Milli" ], "Localization": [ { diff --git a/Common/UnitEnumValues.g.json b/Common/UnitEnumValues.g.json index a0f57154f5..ff3c609a1d 100644 --- a/Common/UnitEnumValues.g.json +++ b/Common/UnitEnumValues.g.json @@ -1876,6 +1876,10 @@ "MillisievertPerHour": 3, "NanosievertPerHour": 2, "RoentgenEquivalentManPerHour": 5, - "SievertPerHour": 6 + "SievertPerHour": 6, + "SievertPerSecond": 16, + "MicrosievertPerSecond": 17, + "MillisievertPerSecond": 14, + "NanosievertPerSecond": 9 } } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index a63670b7be..0071111627 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -61,7 +61,7 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// /// The base unit of RadiationEquivalentDoseRate, which is Second. All conversions go via this value. /// - public static RadiationEquivalentDoseRateUnit BaseUnit { get; } = RadiationEquivalentDoseRateUnit.SievertPerHour; + public static RadiationEquivalentDoseRateUnit BaseUnit { get; } = RadiationEquivalentDoseRateUnit.SievertPerSecond; /// /// Represents the largest possible value of RadiationEquivalentDoseRate. @@ -84,6 +84,11 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// public double MicrosievertsPerHour => As(RadiationEquivalentDoseRateUnit.MicrosievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double MicrosievertsPerSecond => As(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -94,11 +99,21 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// public double MillisievertsPerHour => As(RadiationEquivalentDoseRateUnit.MillisievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double MillisievertsPerSecond => As(RadiationEquivalentDoseRateUnit.MillisievertPerSecond); + /// /// Gets a value of this quantity converted into /// public double NanosievertsPerHour => As(RadiationEquivalentDoseRateUnit.NanosievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double NanosievertsPerSecond => As(RadiationEquivalentDoseRateUnit.NanosievertPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -109,6 +124,11 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// public double SievertsPerHour => As(RadiationEquivalentDoseRateUnit.SievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double SievertsPerSecond => As(RadiationEquivalentDoseRateUnit.SievertPerSecond); + #endregion #region Static Factory Methods @@ -119,6 +139,12 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// If value is NaN or Infinity. public static RadiationEquivalentDoseRate FromMicrosievertsPerHour(double microsievertsperhour) => new RadiationEquivalentDoseRate(microsievertsperhour, RadiationEquivalentDoseRateUnit.MicrosievertPerHour); + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromMicrosievertsPerSecond(double microsievertspersecond) => new RadiationEquivalentDoseRate(microsievertspersecond, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond); + /// /// Creates a from . /// @@ -131,12 +157,24 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// If value is NaN or Infinity. public static RadiationEquivalentDoseRate FromMillisievertsPerHour(double millisievertsperhour) => new RadiationEquivalentDoseRate(millisievertsperhour, RadiationEquivalentDoseRateUnit.MillisievertPerHour); + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromMillisievertsPerSecond(double millisievertspersecond) => new RadiationEquivalentDoseRate(millisievertspersecond, RadiationEquivalentDoseRateUnit.MillisievertPerSecond); + /// /// Creates a from . /// /// If value is NaN or Infinity. public static RadiationEquivalentDoseRate FromNanosievertsPerHour(double nanosievertsperhour) => new RadiationEquivalentDoseRate(nanosievertsperhour, RadiationEquivalentDoseRateUnit.NanosievertPerHour); + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromNanosievertsPerSecond(double nanosievertspersecond) => new RadiationEquivalentDoseRate(nanosievertspersecond, RadiationEquivalentDoseRateUnit.NanosievertPerSecond); + /// /// Creates a from . /// @@ -149,6 +187,12 @@ public RadiationEquivalentDoseRate(double value, RadiationEquivalentDoseRateUnit /// If value is NaN or Infinity. public static RadiationEquivalentDoseRate FromSievertsPerHour(double sievertsperhour) => new RadiationEquivalentDoseRate(sievertsperhour, RadiationEquivalentDoseRateUnit.SievertPerHour); + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromSievertsPerSecond(double sievertspersecond) => new RadiationEquivalentDoseRate(sievertspersecond, RadiationEquivalentDoseRateUnit.SievertPerSecond); + /// /// Dynamically convert from value and unit enum to . /// @@ -189,12 +233,16 @@ private double GetValueInBaseUnit() { return Unit switch { - RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (_value) * 1e-6d, - RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (_value / 100) * 1e-3d, - RadiationEquivalentDoseRateUnit.MillisievertPerHour => (_value) * 1e-3d, - RadiationEquivalentDoseRateUnit.NanosievertPerHour => (_value) * 1e-9d, - RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => _value / 100, - RadiationEquivalentDoseRateUnit.SievertPerHour => _value, + RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (_value/3600) * 1e-6d, + RadiationEquivalentDoseRateUnit.MicrosievertPerSecond => (_value) * 1e-6d, + RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (_value / 100 / 3600) * 1e-3d, + RadiationEquivalentDoseRateUnit.MillisievertPerHour => (_value/3600) * 1e-3d, + RadiationEquivalentDoseRateUnit.MillisievertPerSecond => (_value) * 1e-3d, + RadiationEquivalentDoseRateUnit.NanosievertPerHour => (_value/3600) * 1e-9d, + RadiationEquivalentDoseRateUnit.NanosievertPerSecond => (_value) * 1e-9d, + RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => _value / 100 / 3600, + RadiationEquivalentDoseRateUnit.SievertPerHour => _value/3600, + RadiationEquivalentDoseRateUnit.SievertPerSecond => _value, _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") }; } @@ -208,12 +256,16 @@ private double GetValueAs(RadiationEquivalentDoseRateUnit unit) return unit switch { - RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (baseUnitValue) / 1e-6d, - RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (baseUnitValue * 100) / 1e-3d, - RadiationEquivalentDoseRateUnit.MillisievertPerHour => (baseUnitValue) / 1e-3d, - RadiationEquivalentDoseRateUnit.NanosievertPerHour => (baseUnitValue) / 1e-9d, - RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => baseUnitValue * 100, - RadiationEquivalentDoseRateUnit.SievertPerHour => baseUnitValue, + RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (baseUnitValue*3600) / 1e-6d, + RadiationEquivalentDoseRateUnit.MicrosievertPerSecond => (baseUnitValue) / 1e-6d, + RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (baseUnitValue * 100 * 3600) / 1e-3d, + RadiationEquivalentDoseRateUnit.MillisievertPerHour => (baseUnitValue*3600) / 1e-3d, + RadiationEquivalentDoseRateUnit.MillisievertPerSecond => (baseUnitValue) / 1e-3d, + RadiationEquivalentDoseRateUnit.NanosievertPerHour => (baseUnitValue*3600) / 1e-9d, + RadiationEquivalentDoseRateUnit.NanosievertPerSecond => (baseUnitValue) / 1e-9d, + RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => baseUnitValue * 100 * 3600, + RadiationEquivalentDoseRateUnit.SievertPerHour => baseUnitValue*3600, + RadiationEquivalentDoseRateUnit.SievertPerSecond => baseUnitValue, _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs index 62efff1af1..df74f109e8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs @@ -26,11 +26,15 @@ namespace UnitsNet.Units public enum RadiationEquivalentDoseRateUnit { MicrosievertPerHour = 1, + MicrosievertPerSecond = 17, MilliroentgenEquivalentManPerHour = 4, MillisievertPerHour = 3, + MillisievertPerSecond = 14, NanosievertPerHour = 2, + NanosievertPerSecond = 9, RoentgenEquivalentManPerHour = 5, SievertPerHour = 6, + SievertPerSecond = 16, } #pragma warning restore 1591 diff --git a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensionsTest.g.cs b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensionsTest.g.cs index de765026cd..a66f17ded3 100644 --- a/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensionsTest.g.cs +++ b/UnitsNet.NumberExtensions.Tests/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensionsTest.g.cs @@ -28,6 +28,10 @@ public class NumberToRadiationEquivalentDoseRateExtensionsTests public void NumberToMicrosievertsPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromMicrosievertsPerHour(2), 2.MicrosievertsPerHour()); + [Fact] + public void NumberToMicrosievertsPerSecondTest() => + Assert.Equal(RadiationEquivalentDoseRate.FromMicrosievertsPerSecond(2), 2.MicrosievertsPerSecond()); + [Fact] public void NumberToMilliroentgensEquivalentManPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromMilliroentgensEquivalentManPerHour(2), 2.MilliroentgensEquivalentManPerHour()); @@ -36,10 +40,18 @@ public void NumberToMilliroentgensEquivalentManPerHourTest() => public void NumberToMillisievertsPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromMillisievertsPerHour(2), 2.MillisievertsPerHour()); + [Fact] + public void NumberToMillisievertsPerSecondTest() => + Assert.Equal(RadiationEquivalentDoseRate.FromMillisievertsPerSecond(2), 2.MillisievertsPerSecond()); + [Fact] public void NumberToNanosievertsPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromNanosievertsPerHour(2), 2.NanosievertsPerHour()); + [Fact] + public void NumberToNanosievertsPerSecondTest() => + Assert.Equal(RadiationEquivalentDoseRate.FromNanosievertsPerSecond(2), 2.NanosievertsPerSecond()); + [Fact] public void NumberToRoentgensEquivalentManPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromRoentgensEquivalentManPerHour(2), 2.RoentgensEquivalentManPerHour()); @@ -48,5 +60,9 @@ public void NumberToRoentgensEquivalentManPerHourTest() => public void NumberToSievertsPerHourTest() => Assert.Equal(RadiationEquivalentDoseRate.FromSievertsPerHour(2), 2.SievertsPerHour()); + [Fact] + public void NumberToSievertsPerSecondTest() => + Assert.Equal(RadiationEquivalentDoseRate.FromSievertsPerSecond(2), 2.SievertsPerSecond()); + } } diff --git a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensions.g.cs b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensions.g.cs index 9bec7786d8..724baaf6e1 100644 --- a/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensions.g.cs +++ b/UnitsNet.NumberExtensions/GeneratedCode/NumberToRadiationEquivalentDoseRateExtensions.g.cs @@ -40,6 +40,14 @@ public static RadiationEquivalentDoseRate MicrosievertsPerHour(this T value) #endif => RadiationEquivalentDoseRate.FromMicrosievertsPerHour(Convert.ToDouble(value)); + /// + public static RadiationEquivalentDoseRate MicrosievertsPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDoseRate.FromMicrosievertsPerSecond(Convert.ToDouble(value)); + /// public static RadiationEquivalentDoseRate MilliroentgensEquivalentManPerHour(this T value) where T : notnull @@ -56,6 +64,14 @@ public static RadiationEquivalentDoseRate MillisievertsPerHour(this T value) #endif => RadiationEquivalentDoseRate.FromMillisievertsPerHour(Convert.ToDouble(value)); + /// + public static RadiationEquivalentDoseRate MillisievertsPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDoseRate.FromMillisievertsPerSecond(Convert.ToDouble(value)); + /// public static RadiationEquivalentDoseRate NanosievertsPerHour(this T value) where T : notnull @@ -64,6 +80,14 @@ public static RadiationEquivalentDoseRate NanosievertsPerHour(this T value) #endif => RadiationEquivalentDoseRate.FromNanosievertsPerHour(Convert.ToDouble(value)); + /// + public static RadiationEquivalentDoseRate NanosievertsPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDoseRate.FromNanosievertsPerSecond(Convert.ToDouble(value)); + /// public static RadiationEquivalentDoseRate RoentgensEquivalentManPerHour(this T value) where T : notnull @@ -80,5 +104,13 @@ public static RadiationEquivalentDoseRate SievertsPerHour(this T value) #endif => RadiationEquivalentDoseRate.FromSievertsPerHour(Convert.ToDouble(value)); + /// + public static RadiationEquivalentDoseRate SievertsPerSecond(this T value) + where T : notnull +#if NET7_0_OR_GREATER + , INumber +#endif + => RadiationEquivalentDoseRate.FromSievertsPerSecond(Convert.ToDouble(value)); + } } diff --git a/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseRateTests.cs b/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseRateTests.cs index a0142e1f47..244e522195 100644 --- a/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseRateTests.cs +++ b/UnitsNet.Tests/CustomCode/RadiationEquivalentDoseRateTests.cs @@ -10,12 +10,16 @@ public class RadiationEquivalentDoseRateTests : RadiationEquivalentDoseRateTests { // Override properties in base class here protected override bool SupportsSIUnitSystem => false; - protected override double SievertsPerHourInOneSievertPerHour => 1; - protected override double MillisievertsPerHourInOneSievertPerHour => 1e+3; - protected override double MicrosievertsPerHourInOneSievertPerHour => 1e+6; - protected override double NanosievertsPerHourInOneSievertPerHour => 1e+9; - protected override double RoentgensEquivalentManPerHourInOneSievertPerHour => 100; - protected override double MilliroentgensEquivalentManPerHourInOneSievertPerHour => 1e+5; + protected override double SievertsPerSecondInOneSievertPerSecond => 1; + protected override double MillisievertsPerSecondInOneSievertPerSecond => 1e+3; + protected override double MicrosievertsPerSecondInOneSievertPerSecond => 1e+6; + protected override double NanosievertsPerSecondInOneSievertPerSecond => 1e+9; + protected override double SievertsPerHourInOneSievertPerSecond => 3600; + protected override double MillisievertsPerHourInOneSievertPerSecond => 3.6e+6; + protected override double MicrosievertsPerHourInOneSievertPerSecond => 3.6e+9; + protected override double NanosievertsPerHourInOneSievertPerSecond => 3.6e+12; + protected override double RoentgensEquivalentManPerHourInOneSievertPerSecond => 3.6e+5; + protected override double MilliroentgensEquivalentManPerHourInOneSievertPerSecond => 3.6e+8; [Fact] public void RadiationEquivalentDoseRateTimesTimeSpanEqualsRadiationEquivalentDose() diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 6b689d2377..1a7494646d 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -119,7 +119,7 @@ void Assertion(int expectedValue, Enum expectedUnit, IQuantity quantity) Assertion(3, PressureUnit.Torr, Quantity.From(3, PressureUnit.Torr)); Assertion(3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, Quantity.From(3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond)); Assertion(3, RadiationEquivalentDoseUnit.Sievert, Quantity.From(3, RadiationEquivalentDoseUnit.Sievert)); - Assertion(3, RadiationEquivalentDoseRateUnit.SievertPerHour, Quantity.From(3, RadiationEquivalentDoseRateUnit.SievertPerHour)); + Assertion(3, RadiationEquivalentDoseRateUnit.SievertPerSecond, Quantity.From(3, RadiationEquivalentDoseRateUnit.SievertPerSecond)); Assertion(3, RadiationExposureUnit.Roentgen, Quantity.From(3, RadiationExposureUnit.Roentgen)); Assertion(3, RadioactivityUnit.Terarutherford, Quantity.From(3, RadioactivityUnit.Terarutherford)); Assertion(3, RatioUnit.Percent, Quantity.From(3, RatioUnit.Percent)); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs index 0bb5b6b144..6f7f336f0c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RadiationEquivalentDoseRateTestsBase.g.cs @@ -38,32 +38,44 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class RadiationEquivalentDoseRateTestsBase : QuantityTestsBase { - protected abstract double MicrosievertsPerHourInOneSievertPerHour { get; } - protected abstract double MilliroentgensEquivalentManPerHourInOneSievertPerHour { get; } - protected abstract double MillisievertsPerHourInOneSievertPerHour { get; } - protected abstract double NanosievertsPerHourInOneSievertPerHour { get; } - protected abstract double RoentgensEquivalentManPerHourInOneSievertPerHour { get; } - protected abstract double SievertsPerHourInOneSievertPerHour { get; } + protected abstract double MicrosievertsPerHourInOneSievertPerSecond { get; } + protected abstract double MicrosievertsPerSecondInOneSievertPerSecond { get; } + protected abstract double MilliroentgensEquivalentManPerHourInOneSievertPerSecond { get; } + protected abstract double MillisievertsPerHourInOneSievertPerSecond { get; } + protected abstract double MillisievertsPerSecondInOneSievertPerSecond { get; } + protected abstract double NanosievertsPerHourInOneSievertPerSecond { get; } + protected abstract double NanosievertsPerSecondInOneSievertPerSecond { get; } + protected abstract double RoentgensEquivalentManPerHourInOneSievertPerSecond { get; } + protected abstract double SievertsPerHourInOneSievertPerSecond { get; } + protected abstract double SievertsPerSecondInOneSievertPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global protected virtual double MicrosievertsPerHourTolerance { get { return 1e-5; } } + protected virtual double MicrosievertsPerSecondTolerance { get { return 1e-5; } } protected virtual double MilliroentgensEquivalentManPerHourTolerance { get { return 1e-5; } } protected virtual double MillisievertsPerHourTolerance { get { return 1e-5; } } + protected virtual double MillisievertsPerSecondTolerance { get { return 1e-5; } } protected virtual double NanosievertsPerHourTolerance { get { return 1e-5; } } + protected virtual double NanosievertsPerSecondTolerance { get { return 1e-5; } } protected virtual double RoentgensEquivalentManPerHourTolerance { get { return 1e-5; } } protected virtual double SievertsPerHourTolerance { get { return 1e-5; } } + protected virtual double SievertsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RadiationEquivalentDoseRateUnit unit) { return unit switch { - RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (MicrosievertsPerHourInOneSievertPerHour, MicrosievertsPerHourTolerance), - RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (MilliroentgensEquivalentManPerHourInOneSievertPerHour, MilliroentgensEquivalentManPerHourTolerance), - RadiationEquivalentDoseRateUnit.MillisievertPerHour => (MillisievertsPerHourInOneSievertPerHour, MillisievertsPerHourTolerance), - RadiationEquivalentDoseRateUnit.NanosievertPerHour => (NanosievertsPerHourInOneSievertPerHour, NanosievertsPerHourTolerance), - RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => (RoentgensEquivalentManPerHourInOneSievertPerHour, RoentgensEquivalentManPerHourTolerance), - RadiationEquivalentDoseRateUnit.SievertPerHour => (SievertsPerHourInOneSievertPerHour, SievertsPerHourTolerance), + RadiationEquivalentDoseRateUnit.MicrosievertPerHour => (MicrosievertsPerHourInOneSievertPerSecond, MicrosievertsPerHourTolerance), + RadiationEquivalentDoseRateUnit.MicrosievertPerSecond => (MicrosievertsPerSecondInOneSievertPerSecond, MicrosievertsPerSecondTolerance), + RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour => (MilliroentgensEquivalentManPerHourInOneSievertPerSecond, MilliroentgensEquivalentManPerHourTolerance), + RadiationEquivalentDoseRateUnit.MillisievertPerHour => (MillisievertsPerHourInOneSievertPerSecond, MillisievertsPerHourTolerance), + RadiationEquivalentDoseRateUnit.MillisievertPerSecond => (MillisievertsPerSecondInOneSievertPerSecond, MillisievertsPerSecondTolerance), + RadiationEquivalentDoseRateUnit.NanosievertPerHour => (NanosievertsPerHourInOneSievertPerSecond, NanosievertsPerHourTolerance), + RadiationEquivalentDoseRateUnit.NanosievertPerSecond => (NanosievertsPerSecondInOneSievertPerSecond, NanosievertsPerSecondTolerance), + RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour => (RoentgensEquivalentManPerHourInOneSievertPerSecond, RoentgensEquivalentManPerHourTolerance), + RadiationEquivalentDoseRateUnit.SievertPerHour => (SievertsPerHourInOneSievertPerSecond, SievertsPerHourTolerance), + RadiationEquivalentDoseRateUnit.SievertPerSecond => (SievertsPerSecondInOneSievertPerSecond, SievertsPerSecondTolerance), _ => throw new NotSupportedException() }; } @@ -71,11 +83,15 @@ public abstract partial class RadiationEquivalentDoseRateTestsBase : QuantityTes public static IEnumerable UnitTypes = new List { new object[] { RadiationEquivalentDoseRateUnit.MicrosievertPerHour }, + new object[] { RadiationEquivalentDoseRateUnit.MicrosievertPerSecond }, new object[] { RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour }, new object[] { RadiationEquivalentDoseRateUnit.MillisievertPerHour }, + new object[] { RadiationEquivalentDoseRateUnit.MillisievertPerSecond }, new object[] { RadiationEquivalentDoseRateUnit.NanosievertPerHour }, + new object[] { RadiationEquivalentDoseRateUnit.NanosievertPerSecond }, new object[] { RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour }, new object[] { RadiationEquivalentDoseRateUnit.SievertPerHour }, + new object[] { RadiationEquivalentDoseRateUnit.SievertPerSecond }, }; [Fact] @@ -83,20 +99,20 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { var quantity = new RadiationEquivalentDoseRate(); Assert.Equal(0, quantity.Value); - Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, quantity.Unit); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity.Unit); } [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => new RadiationEquivalentDoseRate(double.PositiveInfinity, RadiationEquivalentDoseRateUnit.SievertPerHour)); - Assert.Throws(() => new RadiationEquivalentDoseRate(double.NegativeInfinity, RadiationEquivalentDoseRateUnit.SievertPerHour)); + Assert.Throws(() => new RadiationEquivalentDoseRate(double.PositiveInfinity, RadiationEquivalentDoseRateUnit.SievertPerSecond)); + Assert.Throws(() => new RadiationEquivalentDoseRate(double.NegativeInfinity, RadiationEquivalentDoseRateUnit.SievertPerSecond)); } [Fact] public void Ctor_WithNaNValue_ThrowsArgumentException() { - Assert.Throws(() => new RadiationEquivalentDoseRate(double.NaN, RadiationEquivalentDoseRateUnit.SievertPerHour)); + Assert.Throws(() => new RadiationEquivalentDoseRate(double.NaN, RadiationEquivalentDoseRateUnit.SievertPerSecond)); } [Fact] @@ -123,7 +139,7 @@ public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() [Fact] public void RadiationEquivalentDoseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() { - var quantity = new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerHour); + var quantity = new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerSecond); QuantityInfo quantityInfo = quantity.QuantityInfo; @@ -135,15 +151,19 @@ public void RadiationEquivalentDoseRate_QuantityInfo_ReturnsQuantityInfoDescribi } [Fact] - public void SievertPerHourToRadiationEquivalentDoseRateUnits() - { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - AssertEx.EqualTolerance(MicrosievertsPerHourInOneSievertPerHour, sievertperhour.MicrosievertsPerHour, MicrosievertsPerHourTolerance); - AssertEx.EqualTolerance(MilliroentgensEquivalentManPerHourInOneSievertPerHour, sievertperhour.MilliroentgensEquivalentManPerHour, MilliroentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(MillisievertsPerHourInOneSievertPerHour, sievertperhour.MillisievertsPerHour, MillisievertsPerHourTolerance); - AssertEx.EqualTolerance(NanosievertsPerHourInOneSievertPerHour, sievertperhour.NanosievertsPerHour, NanosievertsPerHourTolerance); - AssertEx.EqualTolerance(RoentgensEquivalentManPerHourInOneSievertPerHour, sievertperhour.RoentgensEquivalentManPerHour, RoentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(SievertsPerHourInOneSievertPerHour, sievertperhour.SievertsPerHour, SievertsPerHourTolerance); + public void SievertPerSecondToRadiationEquivalentDoseRateUnits() + { + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + AssertEx.EqualTolerance(MicrosievertsPerHourInOneSievertPerSecond, sievertpersecond.MicrosievertsPerHour, MicrosievertsPerHourTolerance); + AssertEx.EqualTolerance(MicrosievertsPerSecondInOneSievertPerSecond, sievertpersecond.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + AssertEx.EqualTolerance(MilliroentgensEquivalentManPerHourInOneSievertPerSecond, sievertpersecond.MilliroentgensEquivalentManPerHour, MilliroentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(MillisievertsPerHourInOneSievertPerSecond, sievertpersecond.MillisievertsPerHour, MillisievertsPerHourTolerance); + AssertEx.EqualTolerance(MillisievertsPerSecondInOneSievertPerSecond, sievertpersecond.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + AssertEx.EqualTolerance(NanosievertsPerHourInOneSievertPerSecond, sievertpersecond.NanosievertsPerHour, NanosievertsPerHourTolerance); + AssertEx.EqualTolerance(NanosievertsPerSecondInOneSievertPerSecond, sievertpersecond.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + AssertEx.EqualTolerance(RoentgensEquivalentManPerHourInOneSievertPerSecond, sievertpersecond.RoentgensEquivalentManPerHour, RoentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(SievertsPerHourInOneSievertPerSecond, sievertpersecond.SievertsPerHour, SievertsPerHourTolerance); + AssertEx.EqualTolerance(SievertsPerSecondInOneSievertPerSecond, sievertpersecond.SievertsPerSecond, SievertsPerSecondTolerance); } [Fact] @@ -153,51 +173,71 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity00.MicrosievertsPerHour, MicrosievertsPerHourTolerance); Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, quantity00.Unit); - var quantity01 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour); - AssertEx.EqualTolerance(1, quantity01.MilliroentgensEquivalentManPerHour, MilliroentgensEquivalentManPerHourTolerance); - Assert.Equal(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, quantity01.Unit); + var quantity01 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond); + AssertEx.EqualTolerance(1, quantity01.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, quantity01.Unit); + + var quantity02 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour); + AssertEx.EqualTolerance(1, quantity02.MilliroentgensEquivalentManPerHour, MilliroentgensEquivalentManPerHourTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, quantity02.Unit); + + var quantity03 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MillisievertPerHour); + AssertEx.EqualTolerance(1, quantity03.MillisievertsPerHour, MillisievertsPerHourTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, quantity03.Unit); + + var quantity04 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MillisievertPerSecond); + AssertEx.EqualTolerance(1, quantity04.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, quantity04.Unit); - var quantity02 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.MillisievertPerHour); - AssertEx.EqualTolerance(1, quantity02.MillisievertsPerHour, MillisievertsPerHourTolerance); - Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, quantity02.Unit); + var quantity05 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.NanosievertPerHour); + AssertEx.EqualTolerance(1, quantity05.NanosievertsPerHour, NanosievertsPerHourTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, quantity05.Unit); - var quantity03 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.NanosievertPerHour); - AssertEx.EqualTolerance(1, quantity03.NanosievertsPerHour, NanosievertsPerHourTolerance); - Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, quantity03.Unit); + var quantity06 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.NanosievertPerSecond); + AssertEx.EqualTolerance(1, quantity06.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, quantity06.Unit); - var quantity04 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour); - AssertEx.EqualTolerance(1, quantity04.RoentgensEquivalentManPerHour, RoentgensEquivalentManPerHourTolerance); - Assert.Equal(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, quantity04.Unit); + var quantity07 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour); + AssertEx.EqualTolerance(1, quantity07.RoentgensEquivalentManPerHour, RoentgensEquivalentManPerHourTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, quantity07.Unit); - var quantity05 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.SievertPerHour); - AssertEx.EqualTolerance(1, quantity05.SievertsPerHour, SievertsPerHourTolerance); - Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, quantity05.Unit); + var quantity08 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.SievertPerHour); + AssertEx.EqualTolerance(1, quantity08.SievertsPerHour, SievertsPerHourTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, quantity08.Unit); + + var quantity09 = RadiationEquivalentDoseRate.From(1, RadiationEquivalentDoseRateUnit.SievertPerSecond); + AssertEx.EqualTolerance(1, quantity09.SievertsPerSecond, SievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity09.Unit); } [Fact] - public void FromSievertsPerHour_WithInfinityValue_ThrowsArgumentException() + public void FromSievertsPerSecond_WithInfinityValue_ThrowsArgumentException() { - Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerHour(double.PositiveInfinity)); - Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerHour(double.NegativeInfinity)); + Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerSecond(double.PositiveInfinity)); + Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerSecond(double.NegativeInfinity)); } [Fact] - public void FromSievertsPerHour_WithNanValue_ThrowsArgumentException() + public void FromSievertsPerSecond_WithNanValue_ThrowsArgumentException() { - Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerHour(double.NaN)); + Assert.Throws(() => RadiationEquivalentDoseRate.FromSievertsPerSecond(double.NaN)); } [Fact] public void As() { - var sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - AssertEx.EqualTolerance(MicrosievertsPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.MicrosievertPerHour), MicrosievertsPerHourTolerance); - AssertEx.EqualTolerance(MilliroentgensEquivalentManPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour), MilliroentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(MillisievertsPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.MillisievertPerHour), MillisievertsPerHourTolerance); - AssertEx.EqualTolerance(NanosievertsPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.NanosievertPerHour), NanosievertsPerHourTolerance); - AssertEx.EqualTolerance(RoentgensEquivalentManPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour), RoentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(SievertsPerHourInOneSievertPerHour, sievertperhour.As(RadiationEquivalentDoseRateUnit.SievertPerHour), SievertsPerHourTolerance); + var sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + AssertEx.EqualTolerance(MicrosievertsPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.MicrosievertPerHour), MicrosievertsPerHourTolerance); + AssertEx.EqualTolerance(MicrosievertsPerSecondInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond), MicrosievertsPerSecondTolerance); + AssertEx.EqualTolerance(MilliroentgensEquivalentManPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour), MilliroentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(MillisievertsPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.MillisievertPerHour), MillisievertsPerHourTolerance); + AssertEx.EqualTolerance(MillisievertsPerSecondInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.MillisievertPerSecond), MillisievertsPerSecondTolerance); + AssertEx.EqualTolerance(NanosievertsPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.NanosievertPerHour), NanosievertsPerHourTolerance); + AssertEx.EqualTolerance(NanosievertsPerSecondInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.NanosievertPerSecond), NanosievertsPerSecondTolerance); + AssertEx.EqualTolerance(RoentgensEquivalentManPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour), RoentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(SievertsPerHourInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.SievertPerHour), SievertsPerHourTolerance); + AssertEx.EqualTolerance(SievertsPerSecondInOneSievertPerSecond, sievertpersecond.As(RadiationEquivalentDoseRateUnit.SievertPerSecond), SievertsPerSecondTolerance); } [Fact] @@ -234,6 +274,20 @@ public void Parse() Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 µSv/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 мкЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = RadiationEquivalentDoseRate.Parse("1 mrem/h", CultureInfo.GetCultureInfo("en-US")); @@ -255,6 +309,20 @@ public void Parse() Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 mSv/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 мЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = RadiationEquivalentDoseRate.Parse("1 nSv/h", CultureInfo.GetCultureInfo("en-US")); @@ -269,6 +337,20 @@ public void Parse() Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 nSv/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 нЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsed = RadiationEquivalentDoseRate.Parse("1 rem/h", CultureInfo.GetCultureInfo("en-US")); @@ -290,6 +372,20 @@ public void Parse() Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, parsed.Unit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 Sv/s", CultureInfo.GetCultureInfo("en-US")); + AssertEx.EqualTolerance(1, parsed.SievertsPerSecond, SievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsed = RadiationEquivalentDoseRate.Parse("1 Зв/с", CultureInfo.GetCultureInfo("ru-RU")); + AssertEx.EqualTolerance(1, parsed.SievertsPerSecond, SievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsed.Unit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + } [Fact] @@ -307,6 +403,18 @@ public void TryParse() Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, parsed.Unit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 µSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 мкЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MicrosievertsPerSecond, MicrosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsed.Unit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParse("1 mrem/h", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.MilliroentgensEquivalentManPerHour, MilliroentgensEquivalentManPerHourTolerance); @@ -325,6 +433,18 @@ public void TryParse() Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, parsed.Unit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 mSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 мЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.MillisievertsPerSecond, MillisievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsed.Unit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParse("1 nSv/h", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.NanosievertsPerHour, NanosievertsPerHourTolerance); @@ -337,6 +457,18 @@ public void TryParse() Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, parsed.Unit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 nSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 нЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.NanosievertsPerSecond, NanosievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsed.Unit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParse("1 rem/h", CultureInfo.GetCultureInfo("en-US"), out var parsed)); AssertEx.EqualTolerance(1, parsed.RoentgensEquivalentManPerHour, RoentgensEquivalentManPerHourTolerance); @@ -355,6 +487,18 @@ public void TryParse() Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, parsed.Unit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 Sv/s", CultureInfo.GetCultureInfo("en-US"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SievertsPerSecond, SievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsed.Unit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParse("1 Зв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsed)); + AssertEx.EqualTolerance(1, parsed.SievertsPerSecond, SievertsPerSecondTolerance); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsed.Unit); + } + } [Fact] @@ -372,6 +516,18 @@ public void ParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("µSv/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("мкЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("mrem/h", CultureInfo.GetCultureInfo("en-US")); @@ -390,6 +546,18 @@ public void ParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("mSv/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("мЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("nSv/h", CultureInfo.GetCultureInfo("en-US")); @@ -402,6 +570,18 @@ public void ParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("nSv/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("нЗв/с", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try { var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("rem/h", CultureInfo.GetCultureInfo("en-US")); @@ -420,6 +600,18 @@ public void ParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, parsedUnit); } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("Sv/s", CultureInfo.GetCultureInfo("en-US")); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + + try + { + var parsedUnit = RadiationEquivalentDoseRate.ParseUnit("Зв/с", CultureInfo.GetCultureInfo("ru-RU")); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsedUnit); + } catch (AmbiguousUnitParseException) { /* Some units have the same abbreviations */ } + } [Fact] @@ -435,6 +627,16 @@ public void TryParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, parsedUnit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("µSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("мкЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, parsedUnit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParseUnit("mrem/h", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, parsedUnit); @@ -450,6 +652,16 @@ public void TryParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerHour, parsedUnit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("mSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("мЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, parsedUnit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParseUnit("nSv/h", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, parsedUnit); @@ -460,6 +672,16 @@ public void TryParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerHour, parsedUnit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("nSv/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("нЗв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, parsedUnit); + } + { Assert.True(RadiationEquivalentDoseRate.TryParseUnit("rem/h", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); Assert.Equal(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, parsedUnit); @@ -475,6 +697,16 @@ public void TryParseUnit() Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerHour, parsedUnit); } + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("Sv/s", CultureInfo.GetCultureInfo("en-US"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsedUnit); + } + + { + Assert.True(RadiationEquivalentDoseRate.TryParseUnit("Зв/с", CultureInfo.GetCultureInfo("ru-RU"), out var parsedUnit)); + Assert.Equal(RadiationEquivalentDoseRateUnit.SievertPerSecond, parsedUnit); + } + } [Theory] @@ -522,73 +754,77 @@ public virtual void ToUnit_FromDefaultQuantity_ReturnsQuantityWithGivenUnit(Radi [Fact] public void ConversionRoundTrip() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMicrosievertsPerHour(sievertperhour.MicrosievertsPerHour).SievertsPerHour, MicrosievertsPerHourTolerance); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMilliroentgensEquivalentManPerHour(sievertperhour.MilliroentgensEquivalentManPerHour).SievertsPerHour, MilliroentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMillisievertsPerHour(sievertperhour.MillisievertsPerHour).SievertsPerHour, MillisievertsPerHourTolerance); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromNanosievertsPerHour(sievertperhour.NanosievertsPerHour).SievertsPerHour, NanosievertsPerHourTolerance); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromRoentgensEquivalentManPerHour(sievertperhour.RoentgensEquivalentManPerHour).SievertsPerHour, RoentgensEquivalentManPerHourTolerance); - AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromSievertsPerHour(sievertperhour.SievertsPerHour).SievertsPerHour, SievertsPerHourTolerance); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMicrosievertsPerHour(sievertpersecond.MicrosievertsPerHour).SievertsPerSecond, MicrosievertsPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMicrosievertsPerSecond(sievertpersecond.MicrosievertsPerSecond).SievertsPerSecond, MicrosievertsPerSecondTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMilliroentgensEquivalentManPerHour(sievertpersecond.MilliroentgensEquivalentManPerHour).SievertsPerSecond, MilliroentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMillisievertsPerHour(sievertpersecond.MillisievertsPerHour).SievertsPerSecond, MillisievertsPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromMillisievertsPerSecond(sievertpersecond.MillisievertsPerSecond).SievertsPerSecond, MillisievertsPerSecondTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromNanosievertsPerHour(sievertpersecond.NanosievertsPerHour).SievertsPerSecond, NanosievertsPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromNanosievertsPerSecond(sievertpersecond.NanosievertsPerSecond).SievertsPerSecond, NanosievertsPerSecondTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromRoentgensEquivalentManPerHour(sievertpersecond.RoentgensEquivalentManPerHour).SievertsPerSecond, RoentgensEquivalentManPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromSievertsPerHour(sievertpersecond.SievertsPerHour).SievertsPerSecond, SievertsPerHourTolerance); + AssertEx.EqualTolerance(1, RadiationEquivalentDoseRate.FromSievertsPerSecond(sievertpersecond.SievertsPerSecond).SievertsPerSecond, SievertsPerSecondTolerance); } [Fact] public void ArithmeticOperators() { - RadiationEquivalentDoseRate v = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - AssertEx.EqualTolerance(-1, -v.SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(2, (RadiationEquivalentDoseRate.FromSievertsPerHour(3)-v).SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(2, (v + v).SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(10, (v*10).SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(10, (10*v).SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(2, (RadiationEquivalentDoseRate.FromSievertsPerHour(10)/5).SievertsPerHour, SievertsPerHourTolerance); - AssertEx.EqualTolerance(2, RadiationEquivalentDoseRate.FromSievertsPerHour(10)/RadiationEquivalentDoseRate.FromSievertsPerHour(5), SievertsPerHourTolerance); + RadiationEquivalentDoseRate v = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + AssertEx.EqualTolerance(-1, -v.SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RadiationEquivalentDoseRate.FromSievertsPerSecond(3)-v).SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(2, (v + v).SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(10, (v*10).SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(10, (10*v).SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(2, (RadiationEquivalentDoseRate.FromSievertsPerSecond(10)/5).SievertsPerSecond, SievertsPerSecondTolerance); + AssertEx.EqualTolerance(2, RadiationEquivalentDoseRate.FromSievertsPerSecond(10)/RadiationEquivalentDoseRate.FromSievertsPerSecond(5), SievertsPerSecondTolerance); } [Fact] public void ComparisonOperators() { - RadiationEquivalentDoseRate oneSievertPerHour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - RadiationEquivalentDoseRate twoSievertsPerHour = RadiationEquivalentDoseRate.FromSievertsPerHour(2); + RadiationEquivalentDoseRate oneSievertPerSecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + RadiationEquivalentDoseRate twoSievertsPerSecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(2); - Assert.True(oneSievertPerHour < twoSievertsPerHour); - Assert.True(oneSievertPerHour <= twoSievertsPerHour); - Assert.True(twoSievertsPerHour > oneSievertPerHour); - Assert.True(twoSievertsPerHour >= oneSievertPerHour); + Assert.True(oneSievertPerSecond < twoSievertsPerSecond); + Assert.True(oneSievertPerSecond <= twoSievertsPerSecond); + Assert.True(twoSievertsPerSecond > oneSievertPerSecond); + Assert.True(twoSievertsPerSecond >= oneSievertPerSecond); - Assert.False(oneSievertPerHour > twoSievertsPerHour); - Assert.False(oneSievertPerHour >= twoSievertsPerHour); - Assert.False(twoSievertsPerHour < oneSievertPerHour); - Assert.False(twoSievertsPerHour <= oneSievertPerHour); + Assert.False(oneSievertPerSecond > twoSievertsPerSecond); + Assert.False(oneSievertPerSecond >= twoSievertsPerSecond); + Assert.False(twoSievertsPerSecond < oneSievertPerSecond); + Assert.False(twoSievertsPerSecond <= oneSievertPerSecond); } [Fact] public void CompareToIsImplemented() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.Equal(0, sievertperhour.CompareTo(sievertperhour)); - Assert.True(sievertperhour.CompareTo(RadiationEquivalentDoseRate.Zero) > 0); - Assert.True(RadiationEquivalentDoseRate.Zero.CompareTo(sievertperhour) < 0); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.Equal(0, sievertpersecond.CompareTo(sievertpersecond)); + Assert.True(sievertpersecond.CompareTo(RadiationEquivalentDoseRate.Zero) > 0); + Assert.True(RadiationEquivalentDoseRate.Zero.CompareTo(sievertpersecond) < 0); } [Fact] public void CompareToThrowsOnTypeMismatch() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.Throws(() => sievertperhour.CompareTo(new object())); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.Throws(() => sievertpersecond.CompareTo(new object())); } [Fact] public void CompareToThrowsOnNull() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.Throws(() => sievertperhour.CompareTo(null)); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.Throws(() => sievertpersecond.CompareTo(null)); } [Theory] - [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerHour, 1, RadiationEquivalentDoseRateUnit.SievertPerHour, true)] // Same value and unit. - [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerHour, 2, RadiationEquivalentDoseRateUnit.SievertPerHour, false)] // Different value. - [InlineData(2, RadiationEquivalentDoseRateUnit.SievertPerHour, 1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, false)] // Different value and unit. - [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerHour, 1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, false)] // Different unit. + [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerSecond, 1, RadiationEquivalentDoseRateUnit.SievertPerSecond, true)] // Same value and unit. + [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerSecond, 2, RadiationEquivalentDoseRateUnit.SievertPerSecond, false)] // Different value. + [InlineData(2, RadiationEquivalentDoseRateUnit.SievertPerSecond, 1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, false)] // Different value and unit. + [InlineData(1, RadiationEquivalentDoseRateUnit.SievertPerSecond, 1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, false)] // Different unit. public void Equals_ReturnsTrue_IfValueAndUnitAreEqual(double valueA, RadiationEquivalentDoseRateUnit unitA, double valueB, RadiationEquivalentDoseRateUnit unitB, bool expectEqual) { var a = new RadiationEquivalentDoseRate(valueA, unitA); @@ -628,32 +864,32 @@ public void Equals_Null_ReturnsFalse() [Fact] public void Equals_RelativeTolerance_IsImplemented() { - var v = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.True(v.Equals(RadiationEquivalentDoseRate.FromSievertsPerHour(1), SievertsPerHourTolerance, ComparisonType.Relative)); - Assert.False(v.Equals(RadiationEquivalentDoseRate.Zero, SievertsPerHourTolerance, ComparisonType.Relative)); - Assert.True(RadiationEquivalentDoseRate.FromSievertsPerHour(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerHour(120), (double)0.3m, ComparisonType.Relative)); - Assert.False(RadiationEquivalentDoseRate.FromSievertsPerHour(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerHour(120), (double)0.1m, ComparisonType.Relative)); + var v = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.True(v.Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(1), SievertsPerSecondTolerance, ComparisonType.Relative)); + Assert.False(v.Equals(RadiationEquivalentDoseRate.Zero, SievertsPerSecondTolerance, ComparisonType.Relative)); + Assert.True(RadiationEquivalentDoseRate.FromSievertsPerSecond(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(120), (double)0.3m, ComparisonType.Relative)); + Assert.False(RadiationEquivalentDoseRate.FromSievertsPerSecond(100).Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(120), (double)0.1m, ComparisonType.Relative)); } [Fact] public void Equals_NegativeRelativeTolerance_ThrowsArgumentOutOfRangeException() { - var v = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.Throws(() => v.Equals(RadiationEquivalentDoseRate.FromSievertsPerHour(1), -1, ComparisonType.Relative)); + var v = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.Throws(() => v.Equals(RadiationEquivalentDoseRate.FromSievertsPerSecond(1), -1, ComparisonType.Relative)); } [Fact] public void EqualsReturnsFalseOnTypeMismatch() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.False(sievertperhour.Equals(new object())); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.False(sievertpersecond.Equals(new object())); } [Fact] public void EqualsReturnsFalseOnNull() { - RadiationEquivalentDoseRate sievertperhour = RadiationEquivalentDoseRate.FromSievertsPerHour(1); - Assert.False(sievertperhour.Equals(null)); + RadiationEquivalentDoseRate sievertpersecond = RadiationEquivalentDoseRate.FromSievertsPerSecond(1); + Assert.False(sievertpersecond.Equals(null)); } [Fact] @@ -679,11 +915,15 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 µSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour).ToString()); + Assert.Equal("1 µSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond).ToString()); Assert.Equal("1 mrem/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour).ToString()); Assert.Equal("1 mSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MillisievertPerHour).ToString()); + Assert.Equal("1 mSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MillisievertPerSecond).ToString()); Assert.Equal("1 nSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.NanosievertPerHour).ToString()); + Assert.Equal("1 nSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.NanosievertPerSecond).ToString()); Assert.Equal("1 rem/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour).ToString()); Assert.Equal("1 Sv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString()); + Assert.Equal("1 Sv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString()); } finally { @@ -698,11 +938,15 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture var swedishCulture = CultureInfo.GetCultureInfo("sv-SE"); Assert.Equal("1 µSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MicrosievertPerHour).ToString(swedishCulture)); + Assert.Equal("1 µSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond).ToString(swedishCulture)); Assert.Equal("1 mrem/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour).ToString(swedishCulture)); Assert.Equal("1 mSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MillisievertPerHour).ToString(swedishCulture)); + Assert.Equal("1 mSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.MillisievertPerSecond).ToString(swedishCulture)); Assert.Equal("1 nSv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.NanosievertPerHour).ToString(swedishCulture)); + Assert.Equal("1 nSv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.NanosievertPerSecond).ToString(swedishCulture)); Assert.Equal("1 rem/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour).ToString(swedishCulture)); Assert.Equal("1 Sv/h", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString(swedishCulture)); + Assert.Equal("1 Sv/s", new RadiationEquivalentDoseRate(1, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString(swedishCulture)); } [Fact] @@ -712,10 +956,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul try { CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; - Assert.Equal("0.1 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s1")); - Assert.Equal("0.12 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s2")); - Assert.Equal("0.123 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s3")); - Assert.Equal("0.1235 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s4")); + Assert.Equal("0.1 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s1")); + Assert.Equal("0.12 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s2")); + Assert.Equal("0.123 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s3")); + Assert.Equal("0.1235 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s4")); } finally { @@ -727,10 +971,10 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixForGivenCulture() { var culture = CultureInfo.InvariantCulture; - Assert.Equal("0.1 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s1", culture)); - Assert.Equal("0.12 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s2", culture)); - Assert.Equal("0.123 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s3", culture)); - Assert.Equal("0.1235 Sv/h", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerHour).ToString("s4", culture)); + Assert.Equal("0.1 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s1", culture)); + Assert.Equal("0.12 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s2", culture)); + Assert.Equal("0.123 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s3", culture)); + Assert.Equal("0.1235 Sv/s", new RadiationEquivalentDoseRate(0.123456, RadiationEquivalentDoseRateUnit.SievertPerSecond).ToString("s4", culture)); } [Theory] @@ -738,7 +982,7 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor [InlineData("en-US")] public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); CultureInfo formatProvider = cultureName == null ? null : CultureInfo.GetCultureInfo(cultureName); @@ -751,154 +995,154 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [InlineData("g")] public void ToString_NullProvider_EqualsCurrentCulture(string format) { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Throws(() => Convert.ToBoolean(quantity)); } [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] public void Convert_ToChar_ThrowsInvalidCastException() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Throws(() => Convert.ToChar(quantity)); } [Fact] public void Convert_ToDateTime_ThrowsInvalidCastException() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Throws(() => Convert.ToDateTime(quantity)); } [Fact] public void Convert_ToDecimal_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((decimal)quantity.Value, Convert.ToDecimal(quantity)); } [Fact] public void Convert_ToDouble_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((double)quantity.Value, Convert.ToDouble(quantity)); } [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] public void Convert_ToString_EqualsToString() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(quantity.ToString(), Convert.ToString(quantity)); } [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] public void Convert_ChangeType_SelfType_EqualsSelf() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(quantity, Convert.ChangeType(quantity, typeof(RadiationEquivalentDoseRate))); } [Fact] public void Convert_ChangeType_UnitType_EqualsUnit() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RadiationEquivalentDoseRateUnit))); } [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(RadiationEquivalentDoseRate.Info, Convert.ChangeType(quantity, typeof(QuantityInfo))); } [Fact] public void Convert_ChangeType_BaseDimensions_EqualsBaseDimensions() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(RadiationEquivalentDoseRate.BaseDimensions, Convert.ChangeType(quantity, typeof(BaseDimensions))); } [Fact] public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Throws(() => Convert.ChangeType(quantity, typeof(QuantityFormatter))); } [Fact] public void GetHashCode_Equals() { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(1.0); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(1.0); Assert.Equal(new {RadiationEquivalentDoseRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } @@ -907,8 +1151,8 @@ public void GetHashCode_Equals() [InlineData(-1.0)] public void NegationOperator_ReturnsQuantity_WithNegatedValue(double value) { - var quantity = RadiationEquivalentDoseRate.FromSievertsPerHour(value); - Assert.Equal(RadiationEquivalentDoseRate.FromSievertsPerHour(-value), -quantity); + var quantity = RadiationEquivalentDoseRate.FromSievertsPerSecond(value); + Assert.Equal(RadiationEquivalentDoseRate.FromSievertsPerSecond(-value), -quantity); } } } diff --git a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs index 2661c97b6d..e9451ae8f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RadiationEquivalentDoseRate.g.cs @@ -61,18 +61,22 @@ namespace UnitsNet static RadiationEquivalentDoseRate() { BaseDimensions = new BaseDimensions(2, 0, -3, 0, 0, 0, 0); - BaseUnit = RadiationEquivalentDoseRateUnit.SievertPerHour; + BaseUnit = RadiationEquivalentDoseRateUnit.SievertPerSecond; Units = Enum.GetValues(typeof(RadiationEquivalentDoseRateUnit)).Cast().ToArray(); Zero = new RadiationEquivalentDoseRate(0, BaseUnit); Info = new QuantityInfo("RadiationEquivalentDoseRate", new UnitInfo[] { new UnitInfo(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, "MicrosievertsPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), + new UnitInfo(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, "MicrosievertsPerSecond", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), new UnitInfo(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, "MilliroentgensEquivalentManPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), new UnitInfo(RadiationEquivalentDoseRateUnit.MillisievertPerHour, "MillisievertsPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), + new UnitInfo(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, "MillisievertsPerSecond", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), new UnitInfo(RadiationEquivalentDoseRateUnit.NanosievertPerHour, "NanosievertsPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), + new UnitInfo(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, "NanosievertsPerSecond", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), new UnitInfo(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, "RoentgensEquivalentManPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), new UnitInfo(RadiationEquivalentDoseRateUnit.SievertPerHour, "SievertsPerHour", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), + new UnitInfo(RadiationEquivalentDoseRateUnit.SievertPerSecond, "SievertsPerSecond", BaseUnits.Undefined, "RadiationEquivalentDoseRate"), }, BaseUnit, Zero, BaseDimensions); @@ -127,7 +131,7 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) public static BaseDimensions BaseDimensions { get; } /// - /// The base unit of RadiationEquivalentDoseRate, which is SievertPerHour. All conversions go via this value. + /// The base unit of RadiationEquivalentDoseRate, which is SievertPerSecond. All conversions go via this value. /// public static RadiationEquivalentDoseRateUnit BaseUnit { get; } @@ -137,7 +141,7 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) public static RadiationEquivalentDoseRateUnit[] Units { get; } /// - /// Gets an instance of this quantity with a value of 0 in the base unit SievertPerHour. + /// Gets an instance of this quantity with a value of 0 in the base unit SievertPerSecond. /// public static RadiationEquivalentDoseRate Zero { get; } @@ -181,6 +185,11 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) /// public double MicrosievertsPerHour => As(RadiationEquivalentDoseRateUnit.MicrosievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double MicrosievertsPerSecond => As(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -191,11 +200,21 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) /// public double MillisievertsPerHour => As(RadiationEquivalentDoseRateUnit.MillisievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double MillisievertsPerSecond => As(RadiationEquivalentDoseRateUnit.MillisievertPerSecond); + /// /// Gets a value of this quantity converted into /// public double NanosievertsPerHour => As(RadiationEquivalentDoseRateUnit.NanosievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double NanosievertsPerSecond => As(RadiationEquivalentDoseRateUnit.NanosievertPerSecond); + /// /// Gets a value of this quantity converted into /// @@ -206,6 +225,11 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) /// public double SievertsPerHour => As(RadiationEquivalentDoseRateUnit.SievertPerHour); + /// + /// Gets a value of this quantity converted into + /// + public double SievertsPerSecond => As(RadiationEquivalentDoseRateUnit.SievertPerSecond); + #endregion #region Static Methods @@ -217,21 +241,29 @@ public RadiationEquivalentDoseRate(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: RadiationEquivalentDoseRateUnit -> BaseUnit - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MillisievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.NanosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MicrosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MillisievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.MillisievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.NanosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.NanosievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerSecond)); // Register in unit converter: BaseUnit <-> BaseUnit - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond, quantity => quantity); // Register in unit converter: BaseUnit -> RadiationEquivalentDoseRateUnit - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MicrosievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MillisievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MillisievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.NanosievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.NanosievertPerHour)); - unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MicrosievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MicrosievertPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MicrosievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MillisievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MillisievertPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MillisievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.MillisievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.NanosievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.NanosievertPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.NanosievertPerSecond, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.NanosievertPerSecond)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour)); + unitConverter.SetConversionFunction(RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerHour, quantity => quantity.ToUnit(RadiationEquivalentDoseRateUnit.SievertPerHour)); } /// @@ -269,6 +301,16 @@ public static RadiationEquivalentDoseRate FromMicrosievertsPerHour(QuantityValue return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.MicrosievertPerHour); } + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromMicrosievertsPerSecond(QuantityValue microsievertspersecond) + { + double value = (double) microsievertspersecond; + return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond); + } + /// /// Creates a from . /// @@ -289,6 +331,16 @@ public static RadiationEquivalentDoseRate FromMillisievertsPerHour(QuantityValue return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.MillisievertPerHour); } + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromMillisievertsPerSecond(QuantityValue millisievertspersecond) + { + double value = (double) millisievertspersecond; + return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.MillisievertPerSecond); + } + /// /// Creates a from . /// @@ -299,6 +351,16 @@ public static RadiationEquivalentDoseRate FromNanosievertsPerHour(QuantityValue return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.NanosievertPerHour); } + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromNanosievertsPerSecond(QuantityValue nanosievertspersecond) + { + double value = (double) nanosievertspersecond; + return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.NanosievertPerSecond); + } + /// /// Creates a from . /// @@ -319,6 +381,16 @@ public static RadiationEquivalentDoseRate FromSievertsPerHour(QuantityValue siev return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.SievertPerHour); } + /// + /// Creates a from . + /// + /// If value is NaN or Infinity. + public static RadiationEquivalentDoseRate FromSievertsPerSecond(QuantityValue sievertspersecond) + { + double value = (double) sievertspersecond; + return new RadiationEquivalentDoseRate(value, RadiationEquivalentDoseRateUnit.SievertPerSecond); + } + /// /// Dynamically convert from value and unit enum to . /// @@ -517,7 +589,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Radia /// Get ratio value from dividing by . public static double operator /(RadiationEquivalentDoseRate left, RadiationEquivalentDoseRate right) { - return left.SievertsPerHour / right.SievertsPerHour; + return left.SievertsPerSecond / right.SievertsPerSecond; } #endregion @@ -812,18 +884,26 @@ private bool TryToUnit(RadiationEquivalentDoseRateUnit unit, [NotNullWhen(true)] RadiationEquivalentDoseRate? convertedOrNull = (Unit, unit) switch { // RadiationEquivalentDoseRateUnit -> BaseUnit - (RadiationEquivalentDoseRateUnit.MicrosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate((_value) * 1e-6d, RadiationEquivalentDoseRateUnit.SievertPerHour), - (RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate((_value / 100) * 1e-3d, RadiationEquivalentDoseRateUnit.SievertPerHour), - (RadiationEquivalentDoseRateUnit.MillisievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate((_value) * 1e-3d, RadiationEquivalentDoseRateUnit.SievertPerHour), - (RadiationEquivalentDoseRateUnit.NanosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate((_value) * 1e-9d, RadiationEquivalentDoseRateUnit.SievertPerHour), - (RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate(_value / 100, RadiationEquivalentDoseRateUnit.SievertPerHour), + (RadiationEquivalentDoseRateUnit.MicrosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value/3600) * 1e-6d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.MicrosievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value) * 1e-6d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value / 100 / 3600) * 1e-3d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.MillisievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value/3600) * 1e-3d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.MillisievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value) * 1e-3d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.NanosievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value/3600) * 1e-9d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.NanosievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate((_value) * 1e-9d, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate(_value / 100 / 3600, RadiationEquivalentDoseRateUnit.SievertPerSecond), + (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.SievertPerSecond) => new RadiationEquivalentDoseRate(_value/3600, RadiationEquivalentDoseRateUnit.SievertPerSecond), // BaseUnit -> RadiationEquivalentDoseRateUnit - (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MicrosievertPerHour) => new RadiationEquivalentDoseRate((_value) / 1e-6d, RadiationEquivalentDoseRateUnit.MicrosievertPerHour), - (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour) => new RadiationEquivalentDoseRate((_value * 100) / 1e-3d, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour), - (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.MillisievertPerHour) => new RadiationEquivalentDoseRate((_value) / 1e-3d, RadiationEquivalentDoseRateUnit.MillisievertPerHour), - (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.NanosievertPerHour) => new RadiationEquivalentDoseRate((_value) / 1e-9d, RadiationEquivalentDoseRateUnit.NanosievertPerHour), - (RadiationEquivalentDoseRateUnit.SievertPerHour, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour) => new RadiationEquivalentDoseRate(_value * 100, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MicrosievertPerHour) => new RadiationEquivalentDoseRate((_value*3600) / 1e-6d, RadiationEquivalentDoseRateUnit.MicrosievertPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond) => new RadiationEquivalentDoseRate((_value) / 1e-6d, RadiationEquivalentDoseRateUnit.MicrosievertPerSecond), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour) => new RadiationEquivalentDoseRate((_value * 100 * 3600) / 1e-3d, RadiationEquivalentDoseRateUnit.MilliroentgenEquivalentManPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MillisievertPerHour) => new RadiationEquivalentDoseRate((_value*3600) / 1e-3d, RadiationEquivalentDoseRateUnit.MillisievertPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.MillisievertPerSecond) => new RadiationEquivalentDoseRate((_value) / 1e-3d, RadiationEquivalentDoseRateUnit.MillisievertPerSecond), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.NanosievertPerHour) => new RadiationEquivalentDoseRate((_value*3600) / 1e-9d, RadiationEquivalentDoseRateUnit.NanosievertPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.NanosievertPerSecond) => new RadiationEquivalentDoseRate((_value) / 1e-9d, RadiationEquivalentDoseRateUnit.NanosievertPerSecond), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour) => new RadiationEquivalentDoseRate(_value * 100 * 3600, RadiationEquivalentDoseRateUnit.RoentgenEquivalentManPerHour), + (RadiationEquivalentDoseRateUnit.SievertPerSecond, RadiationEquivalentDoseRateUnit.SievertPerHour) => new RadiationEquivalentDoseRate(_value*3600, RadiationEquivalentDoseRateUnit.SievertPerHour), _ => null }; diff --git a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.restext b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.restext index bcfa930302..440bd49173 100644 --- a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.restext +++ b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.restext @@ -1,6 +1,10 @@ MicrosievertsPerHour=µSv/h +MicrosievertsPerSecond=µSv/s MilliroentgensEquivalentManPerHour=mrem/h MillisievertsPerHour=mSv/h +MillisievertsPerSecond=mSv/s NanosievertsPerHour=nSv/h +NanosievertsPerSecond=nSv/s RoentgensEquivalentManPerHour=rem/h SievertsPerHour=Sv/h +SievertsPerSecond=Sv/s diff --git a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.ru-RU.restext b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.ru-RU.restext index 967500407a..1898409b5a 100644 --- a/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.ru-RU.restext +++ b/UnitsNet/GeneratedCode/Resources/RadiationEquivalentDoseRate.ru-RU.restext @@ -1,4 +1,8 @@ MicrosievertsPerHour=мкЗв/ч +MicrosievertsPerSecond=мкЗв/с MillisievertsPerHour=мЗв/ч +MillisievertsPerSecond=мЗв/с NanosievertsPerHour=нЗв/ч +NanosievertsPerSecond=нЗв/с SievertsPerHour=Зв/ч +SievertsPerSecond=Зв/с diff --git a/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs index 62efff1af1..df74f109e8 100644 --- a/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RadiationEquivalentDoseRateUnit.g.cs @@ -26,11 +26,15 @@ namespace UnitsNet.Units public enum RadiationEquivalentDoseRateUnit { MicrosievertPerHour = 1, + MicrosievertPerSecond = 17, MilliroentgenEquivalentManPerHour = 4, MillisievertPerHour = 3, + MillisievertPerSecond = 14, NanosievertPerHour = 2, + NanosievertPerSecond = 9, RoentgenEquivalentManPerHour = 5, SievertPerHour = 6, + SievertPerSecond = 16, } #pragma warning restore 1591